Merge commit 'a024bc7d76fcc5e49e8210f9b0896db9ef21861a'

This commit is contained in:
Bjørn Erik Pedersen
2025-02-13 10:40:34 +01:00
817 changed files with 5301 additions and 14766 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,23 @@
{{/*
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" }}
*/}}
{{ $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 }}

View File

@@ -0,0 +1,27 @@
{{ with site.Config.Services.GoogleAnalytics.ID }}
<script
async
src="https://www.googletagmanager.com/gtag/js?id={{ . }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
{{ $site := site.BaseURL | replaceRE "^https?://(www\\.)?([^/]+).*" "$2" }}
gtag('config', '{{ . }}', {'anonymize_ip': true, 'dimension1': '{{ $site }}', 'dimension2': '{{ getenv "BRANCH" }}'});
/**
* Function that tracks a click on an outbound link in Analytics.
* Setting the transport method to 'beacon' lets the hit be sent
* using 'navigator.sendBeacon' in browser that support it.
*/
var trackOutboundLink = function(id, url) {
gtag('event', 'click', {
'event_category': 'outbound',
'event_label': id,
'transport_type': 'beacon'
});
}
</script>
{{ end }}

View File

@@ -0,0 +1,28 @@
{{ $r := .r }}
{{ $attr := .attributes | default dict }}
{{ if hugo.IsDevelopment }}
<link
rel="stylesheet"
href="{{ $r.RelPermalink }}"
{{ template `render-attributes` $attr }} />
{{ else }}
{{ with $r | minify | fingerprint }}
<link
rel="stylesheet"
href="{{ .RelPermalink }}"
integrity="{{ .Data.Integrity }}"
crossorigin="anonymous"
{{ template `render-attributes` $attr }} />
{{ end }}
{{ end }}
{{ define "render-attributes" }}
{{- range $k, $v := . -}}
{{- if $v -}}
{{- printf ` %s=%q` $k $v | safeHTMLAttr -}}
{{- else -}}
{{- printf ` %s` $k | safeHTMLAttr -}}
{{- end -}}
{{- end -}}
{{ end }}

View File

@@ -0,0 +1,15 @@
{{ $r := .r }}
{{ $attr := .attributes | default dict }}
{{ if hugo.IsDevelopment }}
<script
src="{{ $r.RelPermalink }}"
{{ template `render-attributes` $attr }}></script>
{{ else }}
{{ with $r | fingerprint }}
<script
src="{{ .RelPermalink }}"
integrity="{{ .Data.Integrity }}"
crossorigin="anonymous"
{{ template `render-attributes` $attr }}></script>
{{ end }}
{{ end }}

View File

@@ -0,0 +1,25 @@
{{ $image := .image }}
{{ $width := .width | default 1000 }}
{{ $width1x := div $width 2 }}
{{ $imageWebp := $image.Resize (printf "%dx webp" $width) }}
{{ $image1x := $image.Resize (printf "%dx" $width1x) }}
{{ $image1xWebp := $image.Resize (printf "%dx webp" $width1x) }}
{{ $class := .class | default "h-64 tablet:h-96 lg:h-full w-full object-cover lg:absolute" }}
<picture>
<source
srcset="{{ $imageWebp.RelPermalink }}"
type="image/webp"
media="(min-width: 1200px)" />
<source
srcset="{{ $image.RelPermalink }}"
type="image/jpeg"
media="(min-width: 1200px)" />
<source srcset="{{ $image1xWebp.RelPermalink }}" type="image/webp" />
<source srcset="{{ $image1x.RelPermalink }}" type="image/jpeg" />
<img
class="{{ $class }}"
src="{{ $image1x.RelPermalink }}"
alt=""
width="{{ $image1x.Width }}"
height="{{ $image1x.Height }}" />
</picture>