diff --git a/layouts/partials/functions/repo-languages.html b/layouts/partials/functions/repo-languages.html deleted file mode 100644 index 9ac1a6e5..00000000 --- a/layouts/partials/functions/repo-languages.html +++ /dev/null @@ -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) }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 08f93a41..a1db6860 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -54,15 +54,6 @@ {{ $cssZoom := resources.Get "lib/zoom/style.css" }} {{ $assets.Add "css" (slice $cssZoom) }} {{ end }} - {{ $repoLanguages := partial "functions/repo-languages.html" }} - {{ $repoColors := .Site.Data.repoColors }} - {{ range $repoLanguages }} - {{ $color := index $repoColors . | default "#0077b6" }} - {{ $className := printf "background-color-%s" (md5 .) }} - {{ $cssRepoColor := printf ".%s { background-color: %s; }" $className $color }} - {{ $cssRepoColor = $cssRepoColor | resources.FromString (printf "css/background-color.css") }} - {{ $assets.Add "css" (slice $cssRepoColor) }} - {{ end }} {{ $bundleCSS := $assets.Get "css" | resources.Concat "css/main.bundle.css" | resources.Minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }} diff --git a/layouts/shortcodes/codeberg.html b/layouts/shortcodes/codeberg.html index 787db9e4..89201e0f 100644 --- a/layouts/shortcodes/codeberg.html +++ b/layouts/shortcodes/codeberg.html @@ -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 @@

- {{ $language := .language | default "fallback" }} - {{ $className := printf "background-color-%s" (md5 $language) }} + class="mr-1 inline-block h-3 w-3 rounded-full" + style="background-color: {{ if .language }} + {{- index $codebergColors .language -}} + {{ else }} + #0077b6 + {{ end }}">
{{ if .language }}{{ .language }}{{ else }}null{{ end }}
diff --git a/layouts/shortcodes/forgejo.html b/layouts/shortcodes/forgejo.html index a66a2631..d230a4e3 100644 --- a/layouts/shortcodes/forgejo.html +++ b/layouts/shortcodes/forgejo.html @@ -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 @@

- {{ $language := .language | default "fallback" }} - {{ $className := printf "background-color-%s" (md5 $language) }} + class="mr-1 inline-block h-3 w-3 rounded-full" + style="background-color: {{ if .language }} + {{- index $forgejoColors .language -}} + {{ else }} + #0077b6 + {{ end }}">
{{ if .language }}{{ .language }}{{ else }}null{{ end }}
diff --git a/layouts/shortcodes/gitea.html b/layouts/shortcodes/gitea.html index 0be6a064..f8e7531d 100644 --- a/layouts/shortcodes/gitea.html +++ b/layouts/shortcodes/gitea.html @@ -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 @@

- {{ $language := .language | default "fallback" }} - {{ $className := printf "background-color-%s" (md5 $language) }} + class="mr-1 inline-block h-3 w-3 rounded-full" + style="background-color: {{ if .language }} + {{- index $giteaColors .language -}} + {{ else }} + #0077b6 + {{ end }}">
{{ if .language }}{{ .language }}{{ else }}null{{ end }}
diff --git a/layouts/shortcodes/github.html b/layouts/shortcodes/github.html index 2ffc10f4..bad67123 100644 --- a/layouts/shortcodes/github.html +++ b/layouts/shortcodes/github.html @@ -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 @@

- {{ $language := .language | default "fallback" }} - {{ $className := printf "background-color-%s" (md5 $language) }} + class="mr-1 inline-block h-3 w-3 rounded-full" + style="background-color: {{ if .language }} + {{- index $githubColors .language -}} + {{ else }} + #0077b6 + {{ end }}">
{{ if .language }}{{ .language }}{{ else }}null{{ end }}