mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-30 11:13:06 +00:00
27 lines
No EOL
1.5 KiB
HTML
27 lines
No EOL
1.5 KiB
HTML
{{- $assetBusting := partialCached "assetbusting.gotmpl" . }}
|
|
{{- $faviconMatch := false }}
|
|
{{- $svg := dict "ext" "svg" "type" "type=\"image/svg+xml\"" }}
|
|
{{- $png := dict "ext" "png" "type" "type=\"image/png\"" }}
|
|
{{- $ico := dict "ext" "ico" "type" "type=\"image/x-icon\" sizes=\"any\"" }}
|
|
{{- $faviconTypes := slice $svg $png $ico }}
|
|
{{- $faviconNames := slice "favicon" "logo" }}
|
|
{{- range $faviconNames }}
|
|
{{- $faviconName := . }}
|
|
{{- range $faviconTypes }}
|
|
{{- if fileExists (printf "/static/images/%s.%s" $faviconName .ext) }}
|
|
{{- $faviconMatch = true }}
|
|
<link href="{{ printf "images/%s.%s" $faviconName .ext | relURL }}{{ $assetBusting }}" rel="icon" {{ .type | safeHTMLAttr }}>
|
|
{{- end }}
|
|
{{- if (fileExists (printf "/static/images/%s-light.%s" $faviconName .ext)) }}
|
|
{{- $faviconMatch = true }}
|
|
<link href="{{ printf "images/%s-light.%s" $faviconName .ext | relURL }}{{ $assetBusting }}" rel="icon" {{ .type | safeHTMLAttr }} media="(prefers-color-scheme: light)">
|
|
{{- end }}
|
|
{{- if (fileExists (printf "/static/images/%s-dark.%s" $faviconName .ext)) }}
|
|
{{- $faviconMatch = true }}
|
|
<link href="{{ printf "images/%s-dark.%s" $faviconName .ext | relURL }}{{ $assetBusting }}" rel="icon" {{ .type | safeHTMLAttr }} media="(prefers-color-scheme: dark)">
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- if $faviconMatch }}
|
|
{{- break }}
|
|
{{- end }}
|
|
{{- end }} |