Add `fingerprintAlgorithm` parameter

Fixes: #478
pull/567/head
James Panther 2023-05-25 13:58:30 +10:00
parent aa72ff2a73
commit aba3d34482
No known key found for this signature in database
GPG Key ID: D36F789E45745D17
5 changed files with 11 additions and 5 deletions

View File

@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Added ### 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 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)) - Arabic translation ([#521](https://github.com/jpanther/congo/pull/521))
- Slovak translation ([#541](https://github.com/jpanther/congo/pull/541)) - Slovak translation ([#541](https://github.com/jpanther/congo/pull/541))
- Czech translation ([#541](https://github.com/jpanther/congo/pull/541)) - Czech translation ([#541](https://github.com/jpanther/congo/pull/541))

View File

@ -13,11 +13,12 @@ enableSearch = false
enableCodeCopy = false enableCodeCopy = false
# robots = "" # robots = ""
fingerprintAlgorithm = "sha256"
[header] [header]
layout = "basic" # valid options: basic, hamburger, hybrid, custom layout = "basic" # valid options: basic, hamburger, hybrid, custom
# logo = "img/logo.jpg" # 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 showTitle = true
[footer] [footer]

View File

@ -13,10 +13,12 @@ enableSearch = true
enableCodeCopy = true enableCodeCopy = true
# robots = "" # robots = ""
fingerprintAlgorithm = "sha256"
[header] [header]
layout = "basic" # valid options: basic, hamburger, hybrid, custom layout = "basic" # valid options: basic, hamburger, hybrid, custom
# logo = "img/logo.jpg" # logo = "img/logo.jpg"
# logoDark = "img/dark-logo.jpg"
showTitle = true showTitle = true
[footer] [footer]

View File

@ -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.| |`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 `<code>` 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.| |`enableCodeCopy`|`false`|Whether copy-to-clipboard buttons are enabled for `<code>` 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.| |`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.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.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.| |`header.logoDark`|_Not set_|As per the `header.logo` parameter, however this image is used whenever dark mode is active.|

View File

@ -31,6 +31,7 @@
{{ end -}} {{ end -}}
{{/* Asset bundles */}} {{/* Asset bundles */}}
{{ $assets := newScratch }} {{ $assets := newScratch }}
{{ $algorithm := .Site.Params.fingerprintAlgorithm | default "sha256" }}
{{ $cssScheme := resources.Get (printf "css/schemes/%s.css" (lower .Site.Params.colorScheme | default "congo")) }} {{ $cssScheme := resources.Get (printf "css/schemes/%s.css" (lower .Site.Params.colorScheme | default "congo")) }}
{{ if not $cssScheme }} {{ if not $cssScheme }}
{{ $cssScheme = resources.Get "css/schemes/congo.css" }} {{ $cssScheme = resources.Get "css/schemes/congo.css" }}
@ -42,7 +43,7 @@
{{ if $cssCustom }} {{ if $cssCustom }}
{{ $assets.Add "css" (slice $cssCustom) }} {{ $assets.Add "css" (slice $cssCustom) }}
{{ end }} {{ 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 }}
<link <link
type="text/css" type="text/css"
rel="stylesheet" rel="stylesheet"
@ -50,7 +51,7 @@
integrity="{{ $bundleCSS.Data.Integrity }}" integrity="{{ $bundleCSS.Data.Integrity }}"
/> />
{{ $jsAppearance := resources.Get "js/appearance.js" }} {{ $jsAppearance := resources.Get "js/appearance.js" }}
{{ $jsAppearance = $jsAppearance | resources.Minify | resources.Fingerprint "sha512" }} {{ $jsAppearance = $jsAppearance | resources.Minify | resources.Fingerprint $algorithm }}
<script type="text/javascript" src="{{ $jsAppearance.RelPermalink }}" integrity="{{ $jsAppearance.Data.Integrity }}"></script> <script type="text/javascript" src="{{ $jsAppearance.RelPermalink }}" integrity="{{ $jsAppearance.Data.Integrity }}"></script>
{{ if .Site.Params.enableSearch | default false }} {{ if .Site.Params.enableSearch | default false }}
{{ $jsFuse := resources.Get "lib/fuse/fuse.min.js" }} {{ $jsFuse := resources.Get "lib/fuse/fuse.min.js" }}
@ -66,7 +67,7 @@
{{ $assets.Add "js" (slice $jsRTL) }} {{ $assets.Add "js" (slice $jsRTL) }}
{{ end }} {{ end }}
{{ if $assets.Get "js" }} {{ 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 }}
<script defer type="text/javascript" id="script-bundle" src="{{ $bundleJS.RelPermalink }}" integrity="{{ $bundleJS.Data.Integrity }}" data-copy="{{ i18n "code.copy" }}" data-copied="{{ i18n "code.copied" }}"></script> <script defer type="text/javascript" id="script-bundle" src="{{ $bundleJS.RelPermalink }}" integrity="{{ $bundleJS.Data.Integrity }}" data-copy="{{ i18n "code.copy" }}" data-copied="{{ i18n "code.copied" }}"></script>
{{ end }} {{ end }}
{{/* Icons */}} {{/* Icons */}}