mirror of
https://gitee.com/butubb8/blowfish.git
synced 2025-12-05 14:17:50 +08:00
Merge pull request #2332 from ZhenShuo2021/fix/repo-color
🐛 Fix: repo card language color is missed
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
{{ $repoColors := site.Data.repoColors }}
|
||||
{{ $classNameMap := dict }}
|
||||
{{ range $language, $unused := $repoColors }}
|
||||
{{ $className := printf "background-color-%s" (md5 $language) }}
|
||||
{{ $classNameMap = merge $classNameMap (dict $className $language) }}
|
||||
{{ end }}
|
||||
|
||||
{{ $repoLanguages := slice }}
|
||||
{{ range site.Pages }}
|
||||
{{ $matchedClasses := findRE `background-color-[a-f0-9]{32}` .Content }}
|
||||
{{ range $matchedClasses }}
|
||||
{{ with index $classNameMap . }}
|
||||
{{ $repoLanguages = $repoLanguages | append . }}
|
||||
{{ else }}
|
||||
{{ $repoLanguages = $repoLanguages | append "fallback" }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ return (uniq $repoLanguages) }}
|
||||
@@ -1,5 +1,6 @@
|
||||
{{ $id := delimit (slice "codeberg" (partial "functions/uid.html" .)) "-" }}
|
||||
{{- $codebergURL := print "https://codeberg.org/api/v1/repos/" (.Get "repo") -}}
|
||||
{{- $codebergColors := .Site.Data.repoColors -}}
|
||||
{{- $codebergData := dict -}}
|
||||
{{- with try (resources.GetRemote $codebergURL) -}}
|
||||
{{- with .Err -}}
|
||||
@@ -32,10 +33,13 @@
|
||||
</p>
|
||||
|
||||
<div class="m-0 mt-2 flex items-center">
|
||||
{{ $language := .language | default "fallback" }}
|
||||
{{ $className := printf "background-color-%s" (md5 $language) }}
|
||||
<span
|
||||
class="mr-1 inline-block h-3 w-3 rounded-full {{ $className }}"></span>
|
||||
class="mr-1 inline-block h-3 w-3 rounded-full"
|
||||
style="background-color: {{ if .language }}
|
||||
{{- index $codebergColors .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>
|
||||
|
||||
@@ -1,5 +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 -}}
|
||||
{{- $forgejoData := dict -}}
|
||||
{{- with try (resources.GetRemote $forgejoURL) -}}
|
||||
{{- with .Err -}}
|
||||
@@ -32,10 +33,13 @@
|
||||
</p>
|
||||
|
||||
<div class="m-0 mt-2 flex items-center">
|
||||
{{ $language := .language | default "fallback" }}
|
||||
{{ $className := printf "background-color-%s" (md5 $language) }}
|
||||
<span
|
||||
class="mr-1 inline-block h-3 w-3 rounded-full {{ $className }}"></span>
|
||||
class="mr-1 inline-block h-3 w-3 rounded-full"
|
||||
style="background-color: {{ if .language }}
|
||||
{{- index $forgejoColors .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>
|
||||
|
||||
@@ -1,5 +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 -}}
|
||||
{{- $giteaData := dict -}}
|
||||
{{- with try (resources.GetRemote $giteaURL) -}}
|
||||
{{- with .Err -}}
|
||||
@@ -32,10 +33,13 @@
|
||||
</p>
|
||||
|
||||
<div class="m-0 mt-2 flex items-center">
|
||||
{{ $language := .language | default "fallback" }}
|
||||
{{ $className := printf "background-color-%s" (md5 $language) }}
|
||||
<span
|
||||
class="mr-1 inline-block h-3 w-3 rounded-full {{ $className }}"></span>
|
||||
class="mr-1 inline-block h-3 w-3 rounded-full"
|
||||
style="background-color: {{ if .language }}
|
||||
{{- index $giteaColors .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>
|
||||
|
||||
@@ -2,6 +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 -}}
|
||||
{{- $githubData := dict -}}
|
||||
{{- with try (resources.GetRemote $githubURL) -}}
|
||||
{{- with .Err -}}
|
||||
@@ -45,10 +46,13 @@
|
||||
</p>
|
||||
|
||||
<div class="m-0 mt-2 flex items-center">
|
||||
{{ $language := .language | default "fallback" }}
|
||||
{{ $className := printf "background-color-%s" (md5 $language) }}
|
||||
<span
|
||||
class="mr-1 inline-block h-3 w-3 rounded-full {{ $className }}"></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>
|
||||
|
||||
Reference in New Issue
Block a user