Skip to content

Commit ad0378a

Browse files
tlindsay42McShelby
authored andcommitted
Add light & dark theme SVG favicon option
* matcornic#549
1 parent 9dc450a commit ad0378a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

layouts/partials/favicon.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
{{- $assetBusting := not .Site.Params.disableAssetsBusting }}
2-
{{- if (fileExists "/static/images/favicon.svg") }}
2+
{{- if or (fileExists "/static/images/favicon-light.svg") (fileExists "/static/images/favicon-dark.svg") }}
3+
{{/*
4+
Warning: IE and old browser versions do not support media queries necessary for the light & dark theme option.
5+
If you have requirements to support IE and/or older browser versions, use one of the other options.
6+
Reference: https://caniuse.com/css-media-interaction
7+
*/}}
8+
{{- if (fileExists "/static/images/favicon-light.svg") }}
9+
<link href="{{ "images/favicon-light.svg" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="icon" type="image/svg+xml" media="(prefers-color-scheme: light)">
10+
{{- end }}
11+
{{- if (fileExists "/static/images/favicon-dark.svg") }}
12+
<link href="{{ "images/favicon-dark.svg" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="icon" type="image/svg+xml" media="(prefers-color-scheme: dark)">
13+
{{- end }}
14+
{{- else if (fileExists "/static/images/favicon.svg") }}
315
<link href="{{ "images/favicon.svg" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="icon" type="image/svg+xml">
416
{{- else if (fileExists "/static/images/favicon.png") }}
517
<link href="{{ "images/favicon.png" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="icon" type="image/png">

0 commit comments

Comments
 (0)