diff --git a/assets/css/auto.css b/assets/css/auto.css index 9b966e0d28..81b339640c 100644 --- a/assets/css/auto.css +++ b/assets/css/auto.css @@ -1,2 +1,3 @@ -@import "{{ printf "%s-%s.css" .prefix .light }}" screen and (prefers-color-scheme: light); -@import "{{ printf "%s-%s.css" .prefix .dark }}" screen and (prefers-color-scheme: dark); +{{- $assetBusting := partialCached "assetbusting.hugo" . -}} +@import "{{ printf "%s-%s.css%s" .prefix .light $assetBusting }}" screen and (prefers-color-scheme: light); +@import "{{ printf "%s-%s.css%s" .prefix .dark $assetBusting }}" screen and (prefers-color-scheme: dark); diff --git a/assets/css/format-print.css b/assets/css/format-print.css index 90069a3245..9c1f8940fa 100644 --- a/assets/css/format-print.css +++ b/assets/css/format-print.css @@ -1,5 +1,6 @@ -@import "{{ printf "theme-%s.css" .themevariant.identifier }}"; -@import "{{ printf "chroma-%s.css" .themevariant.chroma }}"; +{{- $assetBusting := partialCached "assetbusting.hugo" . -}} +@import "{{ printf "theme-%s.css%s" .themevariant.identifier $assetBusting }}"; +@import "{{ printf "chroma-%s.css%s" .themevariant.chroma $assetBusting }}"; #R-sidebar { display: none; diff --git a/assets/css/print.css b/assets/css/print.css new file mode 100644 index 0000000000..ae99577935 --- /dev/null +++ b/assets/css/print.css @@ -0,0 +1,2 @@ +{{- $assetBusting := partialCached "assetbusting.hugo" . -}} +@import "{{ printf "format-print.css%s" $assetBusting }}"; diff --git a/static/css/swagger.css b/assets/css/swagger.css similarity index 98% rename from static/css/swagger.css rename to assets/css/swagger.css index d78e67abc1..bf5bfeab3b 100644 --- a/static/css/swagger.css +++ b/assets/css/swagger.css @@ -1,7 +1,8 @@ +{{- $assetBusting := partialCached "assetbusting.hugo" . -}} /* Styles to make Swagger-UI fit into our theme */ -@import "fonts.css"; -@import "variant-internal.css"; +@import "{{ printf "fonts.css%s" $assetBusting }}"; +@import "{{ printf "variables.css%s" $assetBusting }}"; body{ line-height: 1.574; diff --git a/assets/css/theme-relearn.css b/assets/css/theme-relearn.css index 36aae7a570..141193bf35 100644 --- a/assets/css/theme-relearn.css +++ b/assets/css/theme-relearn.css @@ -1,3 +1,4 @@ +{{- $assetBusting := partialCached "assetbusting.hugo" . -}} /* this file is here for compatiblity with older installations use theme-relearn-light instead */ -@import "theme-relearn-light.css"; +@import "{{ printf "theme-relearn-light.css%s" $assetBusting }}"; diff --git a/static/css/variant.css b/assets/css/variant.css similarity index 99% rename from static/css/variant.css rename to assets/css/variant.css index 3dab7516d9..e9c3cd552a 100644 --- a/static/css/variant.css +++ b/assets/css/variant.css @@ -1,4 +1,5 @@ -@import "variant-internal.css"; +{{- $assetBusting := partialCached "assetbusting.hugo" . -}} +@import "{{ printf "variables.css%s" $assetBusting }}"; html { color-scheme: only var(--INTERNAL-BROWSER-theme); diff --git a/exampleSite/content/basics/migration/_index.en.md b/exampleSite/content/basics/migration/_index.en.md index ac4f53c805..5306d006cd 100644 --- a/exampleSite/content/basics/migration/_index.en.md +++ b/exampleSite/content/basics/migration/_index.en.md @@ -22,6 +22,8 @@ This document shows you what's new in the latest release and flags it with one o - {{% badge style="note" title=" " %}}Change{{% /badge %}} The [`include` shortcode](shortcodes/include) is now able to resolve links to pages as well as resources or files in the file system (the old behavior). +- {{% badge style="note" title=" " %}}Change{{% /badge %}} To make the asset buster mechanism more robust, some internally used stylesheets where restructured. This generally should not affect your page in any negative way. + - {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The [`openapi` shortcode](shortcodes/openapi) is now able to resolve links to resources as well as to files in the file system (the old behavior). You can configure to generate warnings or errors during build by setting `openapi.errorlevel` to either `warning` or `error` in your `hugo.toml` if a path can not be resolved. --- diff --git a/exampleSite/layouts/partials/menu-footer.html b/exampleSite/layouts/partials/menu-footer.html index 579e8d5a04..c530a191d6 100644 --- a/exampleSite/layouts/partials/menu-footer.html +++ b/exampleSite/layouts/partials/menu-footer.html @@ -1,43 +1,43 @@ - - -

Built with by Hugo

- - \ No newline at end of file + window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => { + setTimeout( githubButtonsInit, 400 ); + }); + + \ No newline at end of file diff --git a/layouts/partials/assetbusting.hugo b/layouts/partials/assetbusting.hugo new file mode 100644 index 0000000000..6911ec8389 --- /dev/null +++ b/layouts/partials/assetbusting.hugo @@ -0,0 +1,6 @@ +{{- $assetsBuster := "" }} +{{- $assetBusting := not site.Params.disableAssetsBusting }} +{{- if $assetBusting }} + {{- $assetsBuster = printf "?%d" now.Unix }} +{{- end }} +{{- return $assetsBuster }} \ No newline at end of file diff --git a/layouts/partials/dependencies/mathjax.html b/layouts/partials/dependencies/mathjax.html index 9b52ba8168..48c6e8c6cd 100644 --- a/layouts/partials/dependencies/mathjax.html +++ b/layouts/partials/dependencies/mathjax.html @@ -2,6 +2,7 @@ {{- $location := .location }} {{- if eq $location "footer" }} {{- with $page }} + {{- $assetBusting := partialCached "assetbusting.hugo" . }} {{- $init := "{}" }} {{- if isset .Params "mathjaxinitialize" }} {{- $init = .Params.mathJaxInitialize }} @@ -27,7 +28,7 @@ {{- else if and (isset .Site.Params "custommathjaxurl") .Site.Params.customMathJaxURL }} {{- else }} - + {{- end }} {{- end }} {{- end }} \ No newline at end of file diff --git a/layouts/partials/dependencies/mermaid.html b/layouts/partials/dependencies/mermaid.html index 4428481af1..764c27baa9 100644 --- a/layouts/partials/dependencies/mermaid.html +++ b/layouts/partials/dependencies/mermaid.html @@ -2,22 +2,23 @@ {{- $location := .location }} {{- if eq $location "footer" }} {{- with $page }} - - - - - - - - - - + {{- $assetBusting := partialCached "assetbusting.hugo" . }} + + + + + + + + + + {{- if and (isset .Params "custommermaidurl") .Params.customMermaidURL }} {{- else if and (isset .Site.Params "custommermaidurl") .Site.Params.customMermaidURL }} {{- else }} - + {{- end }} {{- $init := "{}" }} {{- if isset .Params "mermaidinitialize" }} diff --git a/layouts/partials/dependencies/openapi.html b/layouts/partials/dependencies/openapi.html index 73cefc8893..fd14916e50 100644 --- a/layouts/partials/dependencies/openapi.html +++ b/layouts/partials/dependencies/openapi.html @@ -2,7 +2,8 @@ {{- $location := .location }} {{- if eq $location "footer" }} {{- with $page }} - + {{- $assetBusting := partialCached "assetbusting.hugo" . }} + {{- $urlOpenapi := "" }} {{- $relOpenapi := "" }} {{- $cssInProject := false }} @@ -13,8 +14,8 @@ {{- $urlOpenapi = .Site.Params.customOpenapiURL }} {{- $relOpenapi = .Site.Params.customOpenapiURL }} {{- else }} - {{- $urlOpenapi = printf "%s%s" ("js/swagger-ui/swagger-ui-bundle.js" | relURL) (cond .Site.Params.disableAssetsBusting "" (printf "?%d" now.Unix)) }} - {{- $relOpenapi = printf "%s%s" ("/js/swagger-ui/swagger-ui-bundle.js") (cond .Site.Params.disableAssetsBusting "" (printf "?%d" now.Unix)) }} + {{- $urlOpenapi = printf "%s%s" ("js/swagger-ui/swagger-ui-bundle.js" | relURL) $assetBusting }} + {{- $relOpenapi = printf "%s%s" ("/js/swagger-ui/swagger-ui-bundle.js") $assetBusting }} {{- $cssInProject = true }} {{- end }} @@ -24,7 +25,7 @@ {{- $relOpenapi := replace $relOpenapi "swagger-ui-bundle" "swagger-ui" }} {{- $relOpenapi := replace $relOpenapi ".js" ".css" }} {{- end }} {{- end }} \ No newline at end of file diff --git a/layouts/partials/favicon.html b/layouts/partials/favicon.html index b49a2e23c8..ed1b68850b 100644 --- a/layouts/partials/favicon.html +++ b/layouts/partials/favicon.html @@ -1,4 +1,4 @@ - {{- $assetBusting := not .Site.Params.disableAssetsBusting }} + {{- $assetBusting := partialCached "assetbusting.hugo" . }} {{- $faviconMatch := false }} {{- $svg := dict "ext" "svg" "type" "type=\"image/svg+xml\"" }} {{- $png := dict "ext" "png" "type" "type=\"image/png\"" }} @@ -10,15 +10,15 @@ {{- range $faviconTypes }} {{- if fileExists (printf "/static/images/%s.%s" $faviconName .ext) }} {{- $faviconMatch = true }} - + {{- end }} {{- if (fileExists (printf "/static/images/%s-light.%s" $faviconName .ext)) }} {{- $faviconMatch = true }} - + {{- end }} {{- if (fileExists (printf "/static/images/%s-dark.%s" $faviconName .ext)) }} {{- $faviconMatch = true }} - + {{- end }} {{- end }} {{- if $faviconMatch }} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 4b70bc2d78..6ad8e42d84 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -4,10 +4,11 @@ {{- $outputFormat := partial "output-format.hugo" .Page }} {{- partial "output-partial.hugo" (dict "base" "menu" "page" . "parameter" . "outputFormat" $outputFormat) }} - - +{{- $assetBusting := partialCached "assetbusting.hugo" . }} + + {{- partial "dependencies.html" (dict "page" . "location" "footer" "outputFormat" $outputFormat) }} - + {{- partial "custom-footer.html" . }} diff --git a/layouts/partials/get-theme-variants.hugo b/layouts/partials/get-theme-variants.hugo index 673ae7afa7..61232bd198 100644 --- a/layouts/partials/get-theme-variants.hugo +++ b/layouts/partials/get-theme-variants.hugo @@ -1,6 +1,5 @@ {{- $page := . }} {{- $autores := resources.Get "css/auto.css" }} -{{- $printres := resources.Get "css/format-print.css" }} {{- $nonautothemevariants := slice }} {{- /* we need relearn-light in every case for the print styles */}} {{- $refthemevariants := slice | append "relearn-light" }} @@ -108,7 +107,20 @@ Chroma auto run: {{- end }} {{- end }} -{{- $cssres := $printres | resources.ExecuteAsTemplate "css/format-print.css" (dict "themevariant" (index (collections.Where $themevariants "identifier" "relearn-light") 0)) }} +{{- $swaggerres := resources.Get "css/swagger.css" }} +{{- $cssres := $swaggerres | resources.ExecuteAsTemplate "css/swagger.css" (dict) }} +{{- /* the following code causes Hugo to generate our css file - although it is in comments */}} + +{{- $variantres := resources.Get "css/variant.css" }} +{{- $cssres := $variantres | resources.ExecuteAsTemplate "css/variant.css" (dict) }} +{{- /* the following code causes Hugo to generate our css file - although it is in comments */}} + +{{- $printres := resources.Get "css/print.css" }} +{{- $cssres := $printres | resources.ExecuteAsTemplate "css/print.css" (dict) }} +{{- /* the following code causes Hugo to generate our css file - although it is in comments */}} + +{{- $formatprintres := resources.Get "css/format-print.css" }} +{{- $cssres := $formatprintres | resources.ExecuteAsTemplate "css/format-print.css" (dict "themevariant" (index (collections.Where $themevariants "identifier" "relearn-light") 0)) }} {{- /* the following code causes Hugo to generate our css file - although it is in comments */}} {{- return collections.Where $themevariants "config" true }} diff --git a/layouts/partials/search.html b/layouts/partials/search.html index d12ba72b79..68d9438cd5 100644 --- a/layouts/partials/search.html +++ b/layouts/partials/search.html @@ -15,7 +15,7 @@ {{ if $link }}{{ end }} - {{- $assetBusting := not .Site.Params.disableAssetsBusting }} + {{- $assetBusting := partialCached "assetbusting.hugo" . }} {{- $pageBaseLang := replaceRE "([a-z]+).*" "${1}" .Page.Language.LanguageCode }} {{- $contentlangs := (union (slice | append (.Site.Params.additionalContentLanguage | default slice)) (slice $pageBaseLang)) }} {{- $quotedcontentlangs := slice }} @@ -32,22 +32,22 @@ - - - - + + + + {{- $tinyseg := false }} {{- $wordcut := false }} {{- range $contentlangs }} {{- if and (not $tinyseg) (or (eq . "ja")) }} {{- $tinyseg = true }} - + {{- end }} {{- if and (not $wordcut) (or (eq . "hi") (eq . "th")) }} {{- $wordcut = true }} - + {{- end }} {{- $file := (printf "js/lunr/lunr.%s.min.js" .) }} - + {{- end }} - \ No newline at end of file + \ No newline at end of file diff --git a/layouts/partials/stylesheet.html b/layouts/partials/stylesheet.html index 2f5b9b633b..1d94739aaa 100644 --- a/layouts/partials/stylesheet.html +++ b/layouts/partials/stylesheet.html @@ -5,33 +5,33 @@ {{- $outputFormat = partial "output-format.hugo" $page }} {{- end }} {{- with $page }} - {{- $assetBusting := not .Site.Params.disableAssetsBusting }} + {{- $assetBusting := partialCached "assetbusting.hugo" . }} {{- /* https://github.com/filamentgroup/loadCSS/blob/master/README.md#how-to-use */}} - - - - - - + + + + + + {{- $themevariants := partialCached "get-theme-variants.hugo" . }} {{- with index $themevariants 0 }} - - + + {{- end }} - - + + {{- $f := printf "/static/css/format-%s.css" $outputFormat }} {{- if or (partialCached "fileExists.hugo" $f $f) (resources.Get (printf "/css/format-%s.css" $outputFormat)) }} - + {{- end }} - +