Skip to content

Commit

Permalink
Add light & dark theme SVG favicon option
Browse files Browse the repository at this point in the history
  • Loading branch information
tlindsay42 authored and McShelby committed Jun 5, 2023
1 parent 9dc450a commit ad0378a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion layouts/partials/favicon.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
{{- $assetBusting := not .Site.Params.disableAssetsBusting }}
{{- if (fileExists "/static/images/favicon.svg") }}
{{- if or (fileExists "/static/images/favicon-light.svg") (fileExists "/static/images/favicon-dark.svg") }}
{{/*
Warning: IE and old browser versions do not support media queries necessary for the light & dark theme option.
If you have requirements to support IE and/or older browser versions, use one of the other options.
Reference: https://caniuse.com/css-media-interaction
*/}}
{{- if (fileExists "/static/images/favicon-light.svg") }}
<link href="{{ "images/favicon-light.svg" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="icon" type="image/svg+xml" media="(prefers-color-scheme: light)">
{{- end }}
{{- if (fileExists "/static/images/favicon-dark.svg") }}
<link href="{{ "images/favicon-dark.svg" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="icon" type="image/svg+xml" media="(prefers-color-scheme: dark)">
{{- end }}
{{- else if (fileExists "/static/images/favicon.svg") }}
<link href="{{ "images/favicon.svg" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="icon" type="image/svg+xml">
{{- else if (fileExists "/static/images/favicon.png") }}
<link href="{{ "images/favicon.png" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="icon" type="image/png">
Expand Down

0 comments on commit ad0378a

Please sign in to comment.