Merge pull request #641 from DiogoM1/add_gitlab_shortcode

 Add gitlab shortcode
This commit is contained in:
Nuno Coração 2023-04-10 21:37:06 +01:00 committed by GitHub
commit b041980cc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 1 deletions

View file

@ -296,7 +296,7 @@ In order to add images to the gallery, use `img` tags for each image and add `cl
<!-- prettier-ignore-start --> <!-- prettier-ignore-start -->
| Parameter | Description | | Parameter | Description |
| --------- | ----------------------------------------------------- | |-----------|-------------------------------------------------------|
| `repo` | [String] github repo in the format of `username/repo` | | `repo` | [String] github repo in the format of `username/repo` |
<!-- prettier-ignore-end --> <!-- prettier-ignore-end -->
@ -310,6 +310,30 @@ In order to add images to the gallery, use `img` tags for each image and add `cl
<br/><br/><br/> <br/><br/><br/>
## GitLab Card
`gitlab` allows you to quickly link a GitLab Project (GitLab's jargon for repo).
It displays realtime stats about it, such as the number of stars and forks it has.
Unlike `github` it can't display the main programming language of a project.
Finaly custom GitLab instace URL can be provided, as long as the `api/v4/projects/` endpoint is available, making this shortcode compatible with most self-hosted / entreprise deployments.
<!-- prettier-ignore-start -->
| Parameter | Description |
|-------------|------------------------------------------------------------------------|
| `projectID` | [String] gitlab numeric ProjectID |
| `baseURL` | [String] optional gitlab instace URL, default is `https://gitlab.com/` |
<!-- prettier-ignore-end -->
**Example 1:**
```md
{{</* gitlab projectID="278964" */>}}
```
{{< gitlab projectID="278964" >}}
<br/><br/><br/>
## Icon ## Icon
`icon` outputs an SVG icon and takes the icon name as its only parameter. The icon is scaled to match the current text size. `icon` outputs an SVG icon and takes the icon name as its only parameter. The icon is scaled to match the current text size.

View file

@ -0,0 +1,39 @@
{{- $gitLabData := getJSON (print (default "https://gitlab.com/" (.Get "baseURL")) "api/v4/projects/" (.Get "projectID")) -}}
{{- with $gitLabData -}}
<a target="_blank" href="{{ .html_url }}" class="cursor-pointer">
<div class="w-full md:w-auto pt-3 p-5 border border-neutral-200 dark:border-neutral-700 border-2 rounded-md backdrop-blur shadow-2xl">
<div class="flex items-center">
<span class="text-2xl text-neutral-800 dark:text-neutral" style="margin-right:10px;">
{{ partial "icon.html" "gitlab" }}
</span>
<div class="m-0 font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral">
{{ .name_with_namespace | markdownify | emojify }}
</div>
</div>
<p class="m-0 mt-2 text-md text-neutral-800 dark:text-neutral">
{{ .description | markdownify | emojify }}
</p>
<div class="m-0 mt-2 flex items-center">
<span class="text-md mr-1 text-neutral-800 dark:text-neutral">
{{ partial "icon.html" "star" }}
</span>
<div class="m-0 mr-5 text-md text-neutral-800 dark:text-neutral">
{{ .star_count }}
</div>
<span class="text-md mr-1 text-neutral-800 dark:text-neutral">
{{ partial "icon.html" "fork" }}
</span>
<div class="m-0 mr-5 text-md text-neutral-800 dark:text-neutral">
{{ .forks_count }}
</div>
</div>
</div>
</a>
{{- end -}}