From f90223408c3c861d6f3b905e0240d8d4cb179778 Mon Sep 17 00:00:00 2001 From: Jan Kadlec Date: Fri, 27 Feb 2026 16:18:18 +0100 Subject: [PATCH 1/2] fix(docs): fix version regex in assemble-versions.sh to match major.minor dirs The regex '^[0-9]+$' only matched pure integers but version directories are major.minor (e.g. 1.60). This caused the "promote to latest" step to find nothing, breaking the latest symlink. Updated to match the original generate.sh pattern '^[0-9]+\.[0-9]+$'. jira: trivial risk: nonprod --- scripts/assemble-versions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/assemble-versions.sh b/scripts/assemble-versions.sh index c7a963714..435ad3581 100755 --- a/scripts/assemble-versions.sh +++ b/scripts/assemble-versions.sh @@ -36,7 +36,7 @@ echo "Removing master's latest directory" rm -rf "${content_dir:?}/latest" # 4. Find the highest numbered version and promote it to "latest" -highest_version=$(ls -1 "./$content_dir/" | grep -E '^[0-9]+$' | sort -V | tail -n 1) +highest_version=$(ls -1 "./$content_dir/" | grep -E '^[0-9]+\.[0-9]+$' | sort -V | tail -n 1) if [ -n "$highest_version" ]; then echo "Promoting version $highest_version to /latest" From f3606a2d1e66c032c7b78908fc49f1a92ce8bc20 Mon Sep 17 00:00:00 2001 From: Jan Kadlec Date: Sun, 1 Mar 2026 20:02:23 +0100 Subject: [PATCH 2/2] perf(docs): cache Hugo template partials for 29% faster builds Add partialCached to three hot paths identified via --templateMetrics. head-css.html: SCSS compilation was repeated for all 860+ pages despite identical output. Pass .Site as context so partialCached shares a single cache entry (100% hit rate, was 0%). structureddata.looker.html: iterated ALL site pages to build a title list on every page render, O(n^2) total work. Extract the computation into a cached capital-titles.html partial (84s to 4s). sidebar.html: SVG chevron icon was loaded, minified, and string-replaced inside the recursive nav template (~15k invocations). Extract into cached chevron-svg.html partial (100% hit rate). Verified locally: before/after HTML output is byte-identical (diff -rq). Build time on 864 pages: 18.5s to 13.1s (29% faster). JIRA: trivial risk: nonprod --- docs/layouts/partials/chevron-svg.html | 4 +++ docs/layouts/partials/head-css.html | 2 +- docs/layouts/partials/head.html | 2 +- docs/layouts/partials/sidebar.html | 6 +---- .../structureddata/capital-titles.html | 23 +++++++++++++++++ .../structureddata/structureddata.looker.html | 25 +------------------ 6 files changed, 31 insertions(+), 31 deletions(-) create mode 100644 docs/layouts/partials/chevron-svg.html create mode 100644 docs/layouts/partials/structureddata/capital-titles.html diff --git a/docs/layouts/partials/chevron-svg.html b/docs/layouts/partials/chevron-svg.html new file mode 100644 index 000000000..afe7973f9 --- /dev/null +++ b/docs/layouts/partials/chevron-svg.html @@ -0,0 +1,4 @@ +{{/* Cached chevron SVG icon — loaded and minified once per build. */}} +{{- $icon := resources.Get "icons/chevron-menu.svg" -}} +{{- $svg := $icon | minify -}} +{{- return (replace $svg.Content " diff --git a/docs/layouts/partials/head.html b/docs/layouts/partials/head.html index b29d3b9d3..e6fe3a73f 100644 --- a/docs/layouts/partials/head.html +++ b/docs/layouts/partials/head.html @@ -20,7 +20,7 @@ {{- template "_internal/schema.html" . -}} {{- template "_internal/twitter_cards.html" . -}} -{{ partialCached "head-css.html" . "asdf" }} +{{ partialCached "head-css.html" .Site "head-css" }} - {{ with resources.Get "icons/chevron-menu.svg" }} - {{ $svg := . | minify }} - {{ $svg := replace $svg.Content " {{ end }} diff --git a/docs/layouts/partials/structureddata/capital-titles.html b/docs/layouts/partials/structureddata/capital-titles.html new file mode 100644 index 000000000..2bf3224cc --- /dev/null +++ b/docs/layouts/partials/structureddata/capital-titles.html @@ -0,0 +1,23 @@ +{{/* Returns a slice of unique, capitalized page titles from the site. + Called via partialCached — computed once per build, not per page. */}} +{{- $pageTitles := slice -}} +{{- range .Pages -}} + {{- $pageTitles = $pageTitles | append .Title -}} +{{- end -}} + +{{- $uniquePageTitles := slice -}} +{{- range $pageTitles -}} + {{- if not (in $uniquePageTitles .) -}} + {{- $uniquePageTitles = $uniquePageTitles | append . -}} + {{- end -}} +{{- end -}} + +{{- $capitalTitles := slice -}} +{{- range $uniquePageTitles -}} + {{- $firstChar := substr . 0 1 -}} + {{- if eq $firstChar (upper $firstChar) -}} + {{- $capitalTitles = $capitalTitles | append . -}} + {{- end -}} +{{- end -}} + +{{- return $capitalTitles -}} diff --git a/docs/layouts/partials/structureddata/structureddata.looker.html b/docs/layouts/partials/structureddata/structureddata.looker.html index d6b09b0ad..37e4dd9dd 100644 --- a/docs/layouts/partials/structureddata/structureddata.looker.html +++ b/docs/layouts/partials/structureddata/structureddata.looker.html @@ -1,30 +1,7 @@ {{- $pageData := .Page -}} {{- $siteData := .Site -}} -{{- $sectionTitles := slice -}} -{{- range $siteData.Sections -}} -{{- $sectionTitles = $sectionTitles | append .Title -}} -{{- end -}} - -{{- $pageTitles := slice -}} -{{- range $siteData.Pages -}} -{{- $pageTitles = $pageTitles | append .Title -}} -{{- end -}} - -{{- $uniquePageTitles := slice -}} -{{- range $pageTitles -}} -{{- if not (in $uniquePageTitles .) -}} - {{- $uniquePageTitles = $uniquePageTitles | append . -}} -{{- end -}} -{{- end -}} - -{{- $capitalTitles := slice -}} -{{- range $uniquePageTitles -}} -{{- $firstChar := substr . 0 1 -}} -{{- if eq $firstChar (upper $firstChar) -}} - {{- $capitalTitles = $capitalTitles | append . -}} -{{- end -}} -{{- end -}} +{{- $capitalTitles := partialCached "structureddata/capital-titles.html" $siteData "capital-titles" -}} {{ if in $capitalTitles $pageData.Params.title }} {{ if eq $pageData.Params.title "Introduction" }}