feat(repo-card): fix inline style CSP issue

This commit is contained in:
ZhenShuo Leo
2025-09-07 06:46:55 +08:00
parent 9cc808ea93
commit 2ff90348e7
5 changed files with 34 additions and 39 deletions

View File

@@ -1,6 +1,6 @@
{{ $id := delimit (slice "codeberg" (partial "functions/uid.html" .)) "-" }}
{{- $codebergURL := print "https://codeberg.org/api/v1/repos/" (.Get "repo") -}}
{{- $codebergColors := .Site.Data.repoColors -}}
{{- $repoColors := .Site.Data.repoColors -}}
{{- $codebergData := dict -}}
{{- with try (resources.GetRemote $codebergURL) -}}
{{- with .Err -}}
@@ -33,13 +33,12 @@
</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 $codebergColors .language -}}
{{ else }}
#0077b6
{{ end }}"></span>
{{ $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>
<div class="m-0 mr-5 text-md text-neutral-800 dark:text-neutral">
{{ if .language }}{{ .language }}{{ else }}null{{ end }}
</div>

View File

@@ -1,6 +1,6 @@
{{ $id := delimit (slice "forgejo" (partial "functions/uid.html" .)) "-" }}
{{- $forgejoURL := print (.Get "server" | default .Site.Params.forgejoDefaultServer) "/api/v1/repos/" (.Get "repo") -}}
{{- $forgejoColors := .Site.Data.repoColors -}}
{{- $repoColors := .Site.Data.repoColors -}}
{{- $forgejoData := dict -}}
{{- with try (resources.GetRemote $forgejoURL) -}}
{{- with .Err -}}
@@ -33,13 +33,12 @@
</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 $forgejoColors .language -}}
{{ else }}
#0077b6
{{ end }}"></span>
{{ $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>
<div class="m-0 mr-5 text-md text-neutral-800 dark:text-neutral">
{{ if .language }}{{ .language }}{{ else }}null{{ end }}
</div>

View File

@@ -1,6 +1,6 @@
{{ $id := delimit (slice "gitea" (partial "functions/uid.html" .)) "-" }}
{{- $giteaURL := print (.Get "server" | default .Site.Params.giteaDefaultServer) "/api/v1/repos/" (.Get "repo") -}}
{{- $giteaColors := .Site.Data.repoColors -}}
{{- $repoColors := .Site.Data.repoColors -}}
{{- $giteaData := dict -}}
{{- with try (resources.GetRemote $giteaURL) -}}
{{- with .Err -}}
@@ -33,13 +33,12 @@
</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 $giteaColors .language -}}
{{ else }}
#0077b6
{{ end }}"></span>
{{ $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>
<div class="m-0 mr-5 text-md text-neutral-800 dark:text-neutral">
{{ if .language }}{{ .language }}{{ else }}null{{ end }}
</div>

View File

@@ -2,7 +2,7 @@
{{- $githubURL := print "https://api.github.com/repos/" (.Get "repo") -}}
{{- $githubThumbnailURL := print "https://opengraph.githubassets.com/0/" (.Get "repo") -}}
{{- $showThumbnail := .Get "showThumbnail" | default true -}}
{{- $githubColors := .Site.Data.repoColors -}}
{{- $repoColors := .Site.Data.repoColors -}}
{{- $githubData := dict -}}
{{- with try (resources.GetRemote $githubURL) -}}
{{- with .Err -}}
@@ -46,13 +46,12 @@
</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>
{{ $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>
<div class="m-0 mr-5 text-md text-neutral-800 dark:text-neutral">
{{ if .language }}{{ .language }}{{ else }}null{{ end }}
</div>

View File

@@ -53,13 +53,12 @@
<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 eq $type "model" }}
#ff6b35
{{ else }}
#0077b6
{{ end }}"></span>
{{ $languageDotColor := cond (eq $type "model") "#ff6b35" "#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>
<div class="m-0 mr-5 text-md text-neutral-800 dark:text-neutral">
{{ if eq $type "model" }}
{{ if .pipeline_tag }}{{ .pipeline_tag }}{{ else }}model{{ end }}