perf(repo-card): load CSS once globally instead of per card

This commit is contained in:
ZhenShuo Leo
2025-09-12 10:31:28 +08:00
parent 2ff90348e7
commit f94f60aef6
6 changed files with 34 additions and 30 deletions

View File

@@ -46,12 +46,7 @@
</p>
<div class="m-0 mt-2 flex items-center">
{{ $languageDotColor := cond .language (index $repoColors .language) "#0077b6" }}
{{ $css := resources.FromString (printf "css/%s.css" $id) (printf ".language-dot-%s{background-color:%s}" $id $languageDotColor)
| minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512")
}}
<link rel="stylesheet" href="{{ $css.RelPermalink }}" integrity="{{ $css.Data.Integrity }}">
<span class="mr-1 inline-block h-3 w-3 rounded-full language-dot-{{ $id }}"></span>
<span class="mr-1 inline-block h-3 w-3 rounded-full language-dot" data-language="{{ .language | default "default" }}"></span>
<div class="m-0 mr-5 text-md text-neutral-800 dark:text-neutral">
{{ if .language }}{{ .language }}{{ else }}null{{ end }}
</div>