feat(shortcodes): Display a thumbnail for GitHub repos

This commit is contained in:
Aleksey @soar Smyrnov
2025-05-25 16:08:20 -07:00
committed by Aleksey Smyrnov
parent 1d21656d5e
commit 2bbcd3ab8c
2 changed files with 14 additions and 5 deletions

View File

@@ -2,13 +2,20 @@
{{- $githubURL := print "https://api.github.com/repos/" (.Get "repo") -}}
{{- $githubData := resources.GetRemote $githubURL | transform.Unmarshal -}}
{{- $githubColors := .Site.Data.githubColors -}}
{{- with $githubData -}}
{{- $githubThumbnailURL := print "https://opengraph.githubassets.com/0/" (.Get "repo") -}}
<div class="github-card-wrapper">
{{- if (.Get "showThumbnail") -}}
<div class="w-full thumbnail_card nozoom" style="background-image:url({{ $githubThumbnailURL }});"></div>
{{- end -}}
{{- with $githubData -}}
<a id="{{ $id }}" 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 rounded-md shadow-2xl">
<div class="flex items-center">
<span class="text-2xl text-neutral-800 dark:text-neutral" style="margin-right:10px;">
{{ partial "icon.html" "github" }}
@@ -65,5 +72,6 @@
.catch(error => console.error(error))
</script>
</a>
</div>
{{- end -}}
</div>