From 6ba0ec3ae03d238c645ee4264e86aa90dc1f3c92 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sun, 3 Mar 2024 08:00:52 +0200 Subject: [PATCH 1/3] templates: use `urls.JoinPath` when handling URLs --- site/layouts/_default/examples.html | 2 +- site/layouts/partials/docs-sidebar.html | 2 +- site/layouts/partials/docs-versions.html | 4 ++-- site/layouts/partials/header.html | 2 +- site/layouts/partials/home/plugins.html | 1 + site/layouts/partials/social.html | 6 +++--- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/site/layouts/_default/examples.html b/site/layouts/_default/examples.html index 82e57c1b579f..19aad368d6f5 100644 --- a/site/layouts/_default/examples.html +++ b/site/layouts/_default/examples.html @@ -14,7 +14,7 @@ {{- end }} - {{- $colorModeJS := printf "/docs/%s/assets/js/color-modes.js" $.Site.Params.docs_version -}} + {{- $colorModeJS := urls.JoinPath "/docs" $.Site.Params.docs_version "assets/js/color-modes.js" -}} {{ partial "stylesheet" . }} diff --git a/site/layouts/partials/docs-sidebar.html b/site/layouts/partials/docs-sidebar.html index e7b5576874b3..891a47306aaf 100644 --- a/site/layouts/partials/docs-sidebar.html +++ b/site/layouts/partials/docs-sidebar.html @@ -28,7 +28,7 @@ {{- range $doc := $group.pages -}} {{- $doc_slug := $doc.title | urlize -}} {{- $is_active := and $is_active_group (eq $page_slug $doc_slug) -}} - {{- $href := printf "/docs/%s/%s/%s/" $.Site.Params.docs_version $group_slug $doc_slug }} + {{- $href := urls.JoinPath "/docs" $.Site.Params.docs_version $group_slug $doc_slug "/" }}
  • {{ $doc.title }}
  • {{- end }} diff --git a/site/layouts/partials/docs-versions.html b/site/layouts/partials/docs-versions.html index 7bb7231ef3ae..c465d02e9002 100644 --- a/site/layouts/partials/docs-versions.html +++ b/site/layouts/partials/docs-versions.html @@ -5,9 +5,9 @@ {{- $versions_link := "" -}} {{- if and (eq .Layout "docs") (eq $page_version .Site.Params.docs_version) -}} - {{- $versions_link = printf "%s/%s/" $group_slug $page_slug -}} + {{- $versions_link = urls.JoinPath $group_slug $page_slug "/" -}} {{- else if (eq .Layout "single") -}} - {{- $versions_link = printf "%s/" $page_slug -}} + {{- $versions_link = urls.JoinPath $page_slug "/" -}} {{- end -}} {{- $added_in_51 := eq (string .Page.Params.added.version) "5.1" -}} diff --git a/site/layouts/partials/header.html b/site/layouts/partials/header.html index ff080901e29e..ba58893286a0 100644 --- a/site/layouts/partials/header.html +++ b/site/layouts/partials/header.html @@ -17,7 +17,7 @@ {{- end }} -{{- $colorModeJS := printf "/docs/%s/assets/js/color-modes.js" $.Site.Params.docs_version -}} +{{- $colorModeJS := urls.JoinPath "/docs" $.Site.Params.docs_version "assets/js/color-modes.js" -}} {{ partial "stylesheet" . }} diff --git a/site/layouts/partials/home/plugins.html b/site/layouts/partials/home/plugins.html index ab48d9bc6017..e28ae1bf1f27 100644 --- a/site/layouts/partials/home/plugins.html +++ b/site/layouts/partials/home/plugins.html @@ -50,6 +50,7 @@

    Comprehensive set of plugins


    {{- range $plugin := .Site.Data.plugins -}} + {{- /* TODO we should use urls.JoinPath here too, but the links include `#` which gets escaped */ -}} {{- $href := printf "/docs/%s/%s" $.Site.Params.docs_version $plugin.link }}
    diff --git a/site/layouts/partials/social.html b/site/layouts/partials/social.html index f4f556e5a82e..03658ea9b1bf 100644 --- a/site/layouts/partials/social.html +++ b/site/layouts/partials/social.html @@ -1,11 +1,11 @@ {{- $pageTitle := .Title | markdownify -}} {{- $pageDescription := .Page.Params.description | default .Site.Params.description | markdownify -}} -{{- $socialImagePath := printf "/docs/%s/assets" .Site.Params.docs_version -}} +{{- $socialImagePath := urls.JoinPath "/docs" .Site.Params.docs_version "assets" -}} {{- if .Page.Params.thumbnail -}} - {{- $socialImagePath = path.Join $socialImagePath "img/" .Page.Params.thumbnail -}} + {{- $socialImagePath = urls.JoinPath $socialImagePath "img" .Page.Params.thumbnail -}} {{- else -}} - {{- $socialImagePath = path.Join $socialImagePath "brand/bootstrap-social.png" -}} + {{- $socialImagePath = urls.JoinPath $socialImagePath "brand/bootstrap-social.png" -}} {{- end -}} From 8ea99827d04717ea7d9f6de370b3ca8504f82cd4 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sun, 3 Mar 2024 18:29:49 +0200 Subject: [PATCH 2/3] Update hugo server options Add --noHTTPCache --renderToMemory --printPathWarnings --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 96a3d3dca144..3a1a498f8c6c 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "docs-compile": "npm run docs-build", "docs-vnu": "node build/vnu-jar.mjs", "docs-lint": "npm run docs-vnu", - "docs-serve": "hugo server --port 9001 --disableFastRender --printUnusedTemplates", + "docs-serve": "hugo server --port 9001 --disableFastRender --noHTTPCache --renderToMemory --printPathWarnings --printUnusedTemplates", "docs-serve-only": "npx sirv-cli _site --port 9001", "lockfile-lint": "lockfile-lint --allowed-hosts npm --allowed-schemes https: --empty-hostname false --type npm --path package-lock.json", "update-deps": "ncu -u -x globby,jasmine,karma-browserstack-launcher,karma-rollup-preprocessor && echo Manually update site/assets/js/vendor", From 42b0676a25a3b3babffa4bed60b5b6b05a4df3f5 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 6 Mar 2024 08:09:35 +0200 Subject: [PATCH 3/3] docsref.html: move to variable --- site/layouts/shortcodes/docsref.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/site/layouts/shortcodes/docsref.html b/site/layouts/shortcodes/docsref.html index 2379de2b12e1..06523d859d06 100644 --- a/site/layouts/shortcodes/docsref.html +++ b/site/layouts/shortcodes/docsref.html @@ -1 +1,2 @@ -{{- relref . ((path.Join "docs" $.Site.Params.docs_version (.Get 0)) | relURL) -}} +{{- $pageToReference := path.Join "docs" $.Site.Params.docs_version (.Get 0) -}} +{{- relref . $pageToReference | relURL -}}