diff --git a/config/_default/params.toml b/config/_default/params.toml index fd73946c..299b15f7 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -4,6 +4,7 @@ description = "Hinode is a clean documentation and blog theme for your Hugo site based on Bootstrap 5." enableDarkMode = true modes = ["light", "dark"] + canonifyAssetsURLs = false # toml-docs-end main # toml-docs-start modules diff --git a/layouts/partials/assets/image.html b/layouts/partials/assets/image.html index c3c1d577..60fccd79 100644 --- a/layouts/partials/assets/image.html +++ b/layouts/partials/assets/image.html @@ -15,6 +15,7 @@ --> {{- $validRatios := slice "1x1" "4x3" "16x9" "21x9" -}} +{{- $absoluteURL := site.Params.main.canonifyAssetsURLs | default false -}} {{- $ratio := .ratio -}} {{- $url := .url -}} {{- $mode := false -}} @@ -68,6 +69,7 @@ {{- define "partials/image-scaled.html " -}} + {{- $absoluteURL := site.Params.main.canonifyAssetsURLs | default false -}} {{- $img := .img -}} {{- $ratio := .ratio -}} {{- $imgset := "" -}} @@ -98,7 +100,11 @@ {{- $scaled = $img.Fit (printf "%s webp" $dim) -}} {{- end -}} {{- $scaled = $scaled | resources.Copy (replace $img.RelPermalink $clean (printf "-%s.webp" $dim)) -}} + {{- if $absoluteURL -}} + {{- $imgset = printf "%s, %s %sw" $imgset $scaled.Permalink (index $widths $index) -}} + {{- else -}} {{- $imgset = printf "%s, %s %sw" $imgset $scaled.RelPermalink (index $widths $index) -}} + {{- end -}} {{- end -}} {{- $imgset = strings.TrimPrefix ", " $imgset -}} {{- end -}} @@ -108,6 +114,7 @@ {{- define "partials/image-definition.html" -}} + {{- $absoluteURL := site.Params.main.canonifyAssetsURLs | default false -}} {{- $ratio := .ratio -}} {{- $url := .url -}} {{- $outerClass := .outerClass -}} @@ -125,7 +132,11 @@ {{- $img := partial "utilities/GetImage.html" (dict "url" $url) -}} {{- if $img -}} {{- $fallback := partial "partials/image-default.html" (dict "img" $img "ratio" $ratio) -}} - {{- $fallbackURL = $fallback.RelPermalink -}} + {{- if $absoluteURL -}} + {{- $fallbackURL = $fallback.Permalink -}} + {{- else -}} + {{- $fallbackURL = $fallback.RelPermalink -}} + {{- end -}} {{- $imgset = partial "partials/image-scaled.html " (dict "img" $img "ratio" $ratio) -}} {{- end -}} {{- end -}} diff --git a/layouts/partials/assets/navbar.html b/layouts/partials/assets/navbar.html index d4acace2..05cdcf62 100644 --- a/layouts/partials/assets/navbar.html +++ b/layouts/partials/assets/navbar.html @@ -93,6 +93,7 @@ {{- end -}} +{{- $absoluteURL := site.Params.main.canonifyAssetsURLs | default false -}} {{- $supportedFlags := slice "true" "false" -}} {{- $id := printf "navbar-collapse-%d" 0 -}} @@ -205,7 +206,7 @@ {{- if $logo -}} - {{ $title }} logo + {{ $title }} logo {{- else -}} {{ $title }} {{- end -}} diff --git a/layouts/partials/footer/scripts.html b/layouts/partials/footer/scripts.html index cac76993..1cdc4b2f 100644 --- a/layouts/partials/footer/scripts.html +++ b/layouts/partials/footer/scripts.html @@ -1,3 +1,4 @@ +{{- $absoluteURL := site.Params.main.canonifyAssetsURLs | default false -}} {{- $filename := .filename | default "js/main.bundle.js" -}} {{- $match := .match | default "{js/*.js,js/vendor/**.js}" -}} {{- $page := .page -}} @@ -25,9 +26,9 @@ {{- if gt (len $js.Content) 0 -}} {{- if not hugo.IsProduction -}} - + {{ else -}} {{ $js = $js | minify | fingerprint -}} - + {{ end -}} {{ end -}} diff --git a/layouts/partials/head/favicon.html b/layouts/partials/head/favicon.html index 2520b298..27172992 100644 --- a/layouts/partials/head/favicon.html +++ b/layouts/partials/head/favicon.html @@ -1,10 +1,11 @@ +{{- $absoluteURL := site.Params.main.canonifyAssetsURLs | default false -}} {{ if .Site.Params.favicon.logo -}} {{ $favicon := resources.Get .Site.Params.favicon.logo -}} {{ range $i := .Site.Params.favicon.sizes -}} {{ $image := $favicon.Resize (printf "%dx%d CatmullRom" $i $i) -}} - + {{ end -}} {{ $image := $favicon.Resize "180x CatmullRom" -}} - + {{ end -}} \ No newline at end of file diff --git a/layouts/partials/head/stylesheet.html b/layouts/partials/head/stylesheet.html index f310adf7..a153ab0f 100644 --- a/layouts/partials/head/stylesheet.html +++ b/layouts/partials/head/stylesheet.html @@ -1,3 +1,4 @@ +{{- $absoluteURL := site.Params.main.canonifyAssetsURLs | default false -}} {{- $source := .source | default "scss/app.scss" -}} {{- $target := .target | default "css/main.css" -}} {{- $page := .page -}} @@ -43,8 +44,8 @@ {{- end -}} {{- if not hugo.IsProduction -}} - + {{- else -}} {{- $css = $css | fingerprint | resources.PostProcess -}} - + {{- end -}} \ No newline at end of file