diff --git a/CHANGELOG.md b/CHANGELOG.md index 881701ca..b8874b86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Added - Ability to specify an alternate logo image when dark appearance is active ([#533], ([#521](https://github.com/jpanther/congo/pull/521))(https://github.com/jpanther/congo/pull/533), [#543](https://github.com/jpanther/congo/pull/543)) +- Ability to specify the hashing algorithm that is used when fingerprinting assets ([#478](https://github.com/jpanther/congo/issues/478)) - Arabic translation ([#521](https://github.com/jpanther/congo/pull/521)) - Slovak translation ([#541](https://github.com/jpanther/congo/pull/541)) - Czech translation ([#541](https://github.com/jpanther/congo/pull/541)) diff --git a/config/_default/params.toml b/config/_default/params.toml index c9a9788c..61e2b936 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -13,11 +13,12 @@ enableSearch = false enableCodeCopy = false # robots = "" +fingerprintAlgorithm = "sha256" [header] layout = "basic" # valid options: basic, hamburger, hybrid, custom # logo = "img/logo.jpg" - # darkLogo = "img/dark-logo.jpg" # specify a different logo for dark mode if needed + # logoDark = "img/dark-logo.jpg" showTitle = true [footer] diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 69e16170..21378072 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -13,10 +13,12 @@ enableSearch = true enableCodeCopy = true # robots = "" +fingerprintAlgorithm = "sha256" [header] layout = "basic" # valid options: basic, hamburger, hybrid, custom # logo = "img/logo.jpg" + # logoDark = "img/dark-logo.jpg" showTitle = true [footer] diff --git a/exampleSite/content/docs/configuration/index.md b/exampleSite/content/docs/configuration/index.md index 7531d4f3..47e145fb 100644 --- a/exampleSite/content/docs/configuration/index.md +++ b/exampleSite/content/docs/configuration/index.md @@ -130,6 +130,7 @@ Many of the article defaults here can be overridden on a per article basis by sp |`enableSearch`|`false`|Whether site search is enabled. Set to `true` to enable search functionality. Note that the search feature depends on the `outputs.home` setting in the [site configuration](#site-configuration) being set correctly.| |`enableCodeCopy`|`false`|Whether copy-to-clipboard buttons are enabled for `` blocks. The `highlight.noClasses` parameter must be set to `false` for code copy to function correctly. Read more about [other configuration files](#other-configuration-files) below.| |`robots`|_Not set_|String that indicates how robots should handle your site. If set, it will be output in the page head. Refer to [Google's docs](https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#directives) for valid values.| +|`fingerprintAlgorithm`|`"sha256"`|String that indicates which hashing algorithm is used when fingerprinting assets. Valid options include `md5`, `sha256`, `sha384` and `sha512`.| |`header.layout`|`"basic"`|The layout of the page header and menu. Valid values are `basic`, `hamburger`, `hybrid` or `custom`. When set to `custom`, you must provide your own layout by creating a `/layouts/partials/header/custom.html` file.| |`header.logo`|_Not set_|The relative path to the site logo file within the `assets/` folder. The logo file should be provided at 2x resolution and supports any image dimensions.| |`header.logoDark`|_Not set_|As per the `header.logo` parameter, however this image is used whenever dark mode is active.| diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 857f255b..e2f6adc8 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -31,6 +31,7 @@ {{ end -}} {{/* Asset bundles */}} {{ $assets := newScratch }} + {{ $algorithm := .Site.Params.fingerprintAlgorithm | default "sha256" }} {{ $cssScheme := resources.Get (printf "css/schemes/%s.css" (lower .Site.Params.colorScheme | default "congo")) }} {{ if not $cssScheme }} {{ $cssScheme = resources.Get "css/schemes/congo.css" }} @@ -42,7 +43,7 @@ {{ if $cssCustom }} {{ $assets.Add "css" (slice $cssCustom) }} {{ end }} - {{ $bundleCSS := $assets.Get "css" | resources.Concat "css/main.bundle.css" | resources.Minify | resources.Fingerprint "sha512" }} + {{ $bundleCSS := $assets.Get "css" | resources.Concat "css/main.bundle.css" | resources.Minify | resources.Fingerprint $algorithm }} {{ $jsAppearance := resources.Get "js/appearance.js" }} - {{ $jsAppearance = $jsAppearance | resources.Minify | resources.Fingerprint "sha512" }} + {{ $jsAppearance = $jsAppearance | resources.Minify | resources.Fingerprint $algorithm }} {{ if .Site.Params.enableSearch | default false }} {{ $jsFuse := resources.Get "lib/fuse/fuse.min.js" }} @@ -66,7 +67,7 @@ {{ $assets.Add "js" (slice $jsRTL) }} {{ end }} {{ if $assets.Get "js" }} - {{ $bundleJS := $assets.Get "js" | resources.Concat "js/main.bundle.js" | resources.Minify | resources.Fingerprint "sha512" }} + {{ $bundleJS := $assets.Get "js" | resources.Concat "js/main.bundle.js" | resources.Minify | resources.Fingerprint $algorithm }} {{ end }} {{/* Icons */}} @@ -111,4 +112,4 @@ {{ if templates.Exists "partials/extend-head.html" }} {{ partial "extend-head.html" .Site }} {{ end }} - \ No newline at end of file +