Merge commit 'b3d87dd0fd746f07f9afa6e6a2969aea41da6a38'

This commit is contained in:
Bjørn Erik Pedersen
2025-04-24 10:23:16 +02:00
101 changed files with 503 additions and 164 deletions

View File

@@ -0,0 +1,25 @@
{{ $colors := slice "slate" "green" "cyan" "blue" }}
{{ with .single }}
{{ $colors = slice . }}
{{ end }}
{{ $shades := slice 300 400 500 }}
{{ if not .dark }}
{{ $shades = slice 700 800 }}
{{ end }}
{{ $hash := (hash.FNV32a .text) }}
{{ $i := mod $hash (len $colors) }}
{{ $j := mod $hash (len $shades) }}
{{ $color := index $colors $i }}
{{ $shade1 := index $shades $j }}
{{ $shade2 := 0 }}
{{ $shade3 := 0 }}
{{ if gt $shade1 500 }}
{{ $shade2 = math.Min (sub $shade1 500) 100 | int }}
{{ $shade3 = sub $shade1 100 }}
{{ else }}
{{ $shade2 = math.Max (add $shade1 500) 700 | int }}
{{ $shade3 = add $shade1 200 }}
{{ end }}
{{ $res := dict "color" $color "shade1" $shade1 "shade2" $shade2 "shade3" $shade3 }}
{{ return $res }}

View File

@@ -0,0 +1,28 @@
{{ $url := "https://api.github.com/repos/gohugoio/hugo" }}
{{ $cacheKey := print $url (now.Format "2006-01-02") }}
{{ $headers := dict }}
{{ with os.Getenv "HUGO_GH_TOKEN" }}
{{ $headers = dict "Authorization" (printf "Bearer %s" .) }}
{{ end }}
{{ $opts := dict "headers" $headers "key" $cacheKey }}
{{ $githubRepoInfo := dict }}
{{ with try (resources.GetRemote $url $opts) }}
{{ with .Err }}
{{ warnf "Failed to get GitHub repo info: %s" . }}
{{ else with (.Value | transform.Unmarshal) }}
{{ $githubRepoInfo = dict
"html_url" .html_url
"stargazers_url" .stargazers_url
"watchers_count" .watchers_count
"stargazers_count" .stargazers_count
"forks_count" .forks_count
"contributors_url" .contributors_url
"releases_url" .releases_url
"forks_count" .forks_count
}}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ end }}
{{ return $githubRepoInfo }}

View File

@@ -0,0 +1,24 @@
{{/* prettier-ignore-start */ -}}
{{/*
Parses the serialized data from the given URL and returns a map or an array.
Supports CSV, JSON, TOML, YAML, and XML.
@param {string} . The URL from which to retrieve the serialized data.
@returns {any}
@example {{ partial "get-remote-data.html" "https://example.org/foo.json" }}
*/}}
{{/* prettier-ignore-end */ -}}
{{ $url := . }}
{{ $data := dict }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else with .Value }}
{{ $data = .Content | transform.Unmarshal }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ end }}
{{ return $data }}