Files
blowfish/layouts/shortcodes/github.html
Served Smart 9f85c0566e ♻️ refactor: Move most inline styles out of line
- Move out of line by using already defined css classes
- Move paddings out of line
- Move margins out of line
- Move z-indexes out of line
- Move center-relative-left out of line
2025-06-12 14:00:21 +02:00

86 lines
3.2 KiB
HTML

{{ $id := delimit (slice "github" (partial "functions/uid.html" .)) "-" }}
{{- $githubURL := print "https://api.github.com/repos/" (.Get "repo") -}}
{{- $githubData := resources.GetRemote $githubURL | transform.Unmarshal -}}
{{- $githubColors := .Site.Data.githubColors -}}
{{- $githubThumbnailURL := print "https://opengraph.githubassets.com/0/" (.Get "repo") -}}
{{- $showThumbnail := .Get "showThumbnail" | default true -}}
<div class="github-card-wrapper">
{{- with $githubData -}}
<a id="{{ $id }}" target="_blank" href="{{ .html_url }}" class="cursor-pointer">
<div
class="w-full md:w-auto p-0 m-0 border border-neutral-200 dark:border-neutral-700 border rounded-md shadow-2xl">
{{- if $showThumbnail -}}
<div class="w-full nozoom">
<img src="{{ $githubThumbnailURL }}" alt="GitHub Repository Thumbnail"
class="nozoom mt-0 mb-0 w-full h-full object-cover">
</div>
{{- end -}}
<div
class="w-full md:w-auto pt-3 p-5">
<div class="flex items-center">
<span class="text-2xl text-neutral-800 dark:text-neutral margin-right-[10px]">
{{ partial "icon.html" "github" }}
</span>
<div id="{{ $id }}-full_name"
class="m-0 font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral">
{{ .full_name | markdownify }}
</div>
</div>
<p id="{{ $id }}-description" class="m-0 mt-2 text-md text-neutral-800 dark:text-neutral">
{{ .description | markdownify }}
</p>
<div class="m-0 mt-2 flex items-center">
<span class="mr-1 inline-block h-3 w-3 rounded-full"
style="background-color: {{ if .language }} {{- index $githubColors .language -}} {{ else }} #0077b6 {{ end }}"></span>
<div class="m-0 mr-5 text-md text-neutral-800 dark:text-neutral">
{{ if .language }} {{ .language }} {{ else }} null {{ end }}
</div>
<span class="text-md mr-1 text-neutral-800 dark:text-neutral">
{{ partial "icon.html" "star" }}
</span>
<div id="{{ $id }}-stargazers" class="m-0 mr-5 text-md text-neutral-800 dark:text-neutral">
{{ .stargazers_count }}
</div>
<span class="text-md mr-1 text-neutral-800 dark:text-neutral">
{{ partial "icon.html" "fork" }}
</span>
<div id="{{ $id }}-forks" class="m-0 mr-5 text-md text-neutral-800 dark:text-neutral">
{{ .forks }}
</div>
</div>
</div>
</div>
<script>
fetch({{ $githubURL }}, {
headers: new Headers({
'User-agent': 'Mozilla/4.0 Custom User Agent'
})
})
.then(response => response.json())
.then(data => {
document.getElementById('{{ $id }}-full_name').innerHTML = data.full_name;
document.getElementById('{{ $id }}-description').innerHTML = data.description;
document.getElementById('{{ $id }}-stargazers').innerHTML = data.stargazers_count;
document.getElementById('{{ $id }}-forks').innerHTML = data.forks;
})
.catch(error => console.error(error))
</script>
</a>
{{- end -}}
</div>