mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-01-30 16:31:52 +01:00
made github and gitlab shortcodes dynamic
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
{{- $gitLabData := getJSON (print (default "https://gitlab.com/" (.Get "baseURL")) "api/v4/projects/" (.Get "projectID")) -}}
|
||||
{{ $id := delimit (slice "gitlab" .Ordinal now.UnixNano) "-" }}
|
||||
{{- $gitlabURL := print (default "https://gitlab.com/" (.Get "baseURL")) "api/v4/projects/" (.Get "projectID") -}}
|
||||
|
||||
{{- $gitLabData := getJSON ($gitlabURL) -}}
|
||||
{{- with $gitLabData -}}
|
||||
|
||||
<a target="_blank" href="{{ .html_url }}" class="cursor-pointer">
|
||||
@@ -8,12 +11,12 @@
|
||||
<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">
|
||||
<div id="{{ $id }}-name_with_namespace" 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">
|
||||
<p id="{{ $id }}-description" class="m-0 mt-2 text-md text-neutral-800 dark:text-neutral">
|
||||
{{ .description | markdownify | emojify }}
|
||||
</p>
|
||||
|
||||
@@ -21,19 +24,36 @@
|
||||
<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">
|
||||
<div id="{{ $id }}-star_count" 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">
|
||||
<div id="{{ $id }}-forks_count" class="m-0 mr-5 text-md text-neutral-800 dark:text-neutral">
|
||||
{{ .forks_count }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
console.log({{ $gitlabURL }})
|
||||
fetch({{ $gitlabURL }}, {
|
||||
headers: new Headers({
|
||||
'User-agent': 'Mozilla/4.0 Custom User Agent'
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log(data)
|
||||
document.getElementById('{{ $id }}-name_with_namespace').innerHTML = data.name_with_namespace;
|
||||
document.getElementById('{{ $id }}-description').innerHTML = data.description;
|
||||
document.getElementById('{{ $id }}-star_count').innerHTML = data.star_count;
|
||||
document.getElementById('{{ $id }}-forks_count').innerHTML = data.forks_count;
|
||||
})
|
||||
.catch(error => console.error(error))
|
||||
</script>
|
||||
</a>
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user