favicon: respect assets directory #1023

This commit is contained in:
Sören Weber 2025-02-15 03:03:16 +01:00
parent ad60ecdaa8
commit 0a3121be8f
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
4 changed files with 17 additions and 6 deletions

View file

@ -7,9 +7,9 @@ weight = 1
## Change the Favicon
If your favicon is an SVG, PNG, or ICO, just drop your image in your site's `static/images/` directory and name it `favicon.svg`, `favicon.png`, or `favicon.ico` respectively.
If your favicon is an SVG, PNG, or ICO, just drop your image in your site's `assets/images/` or `static/images/` directory and name it `favicon.svg`, `favicon.png`, or `favicon.ico` respectively.
If you want to adjust your favicon according to your OS settings for light/dark mode, add the image files `static/images/favicon-light.svg` and `static/images/favicon-dark.svg` to your site's directory, respectively, corresponding to your file format. In case some of the files are missing, the theme falls back to `favicon.svg` for each missing file. All supplied favicons must be of the same file format.
If you want to adjust your favicon according to your OS settings for light/dark mode, add the image files `assets/images/favicon-light.svg` and `assets/images/favicon-dark.svg` to your site's directory, respectively, corresponding to your file format. In case some of the files are missing, the theme falls back to `favicon.svg` for each missing file. All supplied favicons must be of the same file format.
If no favicon file is found, the theme will look up the alternative filename `logo` in the same location and will repeat the search for the list of supported file types.

View file

@ -50,6 +50,8 @@ weight = -4
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The logo color is now configurable via the `--MENU-HEADER-color` variable in your variant stylesheets.
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Now favicons are also searched in the `assets/images` directory.
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Table headers are sticky now.
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The themes documentation has been moved from `exampleSite` to `docs` to make place for a [brand new exampleSite](https://mcshelby.github.io/hugo-theme-relearn/exampleSite/about/index.html).

View file

@ -8,15 +8,24 @@
{{- range $faviconNames }}
{{- $faviconName := . }}
{{- range $faviconTypes }}
{{- if fileExists (printf "/static/images/%s.%s" $faviconName .ext) }}
{{- if or
(resources.Get (printf "/images/%s.%s" $faviconName .ext))
(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)) }}
{{- if or
(resources.Get (printf "/images/%s-light.%s" $faviconName .ext))
(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)) }}
{{- if or
(resources.Get (printf "/images/%s-dark.%s" $faviconName .ext))
(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 }}

View file

@ -1 +1 @@
7.3.2+39e67e57efafc2d00755d455c30157d5fbfb3dd0
7.3.2+ad60ecdaa817b167fe3b06c421040a92717b367a