From 9e3a1cd61abdb23b062098be8217316d2bf226aa Mon Sep 17 00:00:00 2001 From: tannevaled Date: Tue, 27 Oct 2026 21:21:59 +0100 Subject: [PATCH] chore(docs): native version selector and Go page history (hextra v0.21.0) Bumps themes/hextra to v0.21.0 and - drops the local selector (layouts/_partials/custom/version-select.html and its .fs-version-select CSS): the menu item uses the theme's components/version-select.html, which now has hidden versions, aliases and the language fallback chain; - generates data/pagehistory.json with the theme's Go program (go run github.com/tannevaled/hextra/cmd/pagehistory@v0.21.0) instead of the deprecated shell script; the JSON is byte-identical. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/docs.yml | 2 +- .gitignore | 2 +- README.md | 3 +- assets/css/custom.css | 1 - hugo.yaml | 4 +- layouts/_partials/custom/version-select.html | 118 ------------------- themes/hextra | 2 +- 7 files changed, 6 insertions(+), 126 deletions(-) delete mode 100644 layouts/_partials/custom/version-select.html diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 568060c..9363e04 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -73,7 +73,7 @@ jobs: - name: Page history run: | mkdir -p data - sh themes/hextra/scripts/page-history.sh > data/pagehistory.json + go run github.com/tannevaled/hextra/cmd/pagehistory@v0.21.0 > data/pagehistory.json # --panicOnWarning: a deprecated setting or a template warning fails the # build rather than scrolling by. A broken {{< relref >}} is an error. diff --git a/.gitignore b/.gitignore index 7cd05fc..e280db2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,5 @@ .hugo_build.lock .DS_Store -# Written by themes/hextra/scripts/page-history.sh before each build (CI and local). +# Written by the theme's cmd/pagehistory before each build (CI and local). /data/pagehistory.json diff --git a/README.md b/README.md index 92fe005..c068fff 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,6 @@ cd figures && go run . | `figures/` | the Go module that draws every figure, one file each | | `layouts/_shortcodes/plotfig.html` | a figure and the code that drew it | | `static/images/figures/` | the figures, as `figures/` writes them | -| `layouts/_partials/custom/version-select.html` | the version selector (reads `versions.json`), from go-ndarray/docs | | `layouts/_partials/custom/content-begin.html` | the outdated-version banner (reads `versions.json`) | | `layouts/_partials/favicons.html` | the brand's favicons | | `assets/css/custom.css` | the brand blue as Hextra's primary colour, the table headers, a white card under figures | @@ -67,7 +66,7 @@ cd figures && go run . ```sh git clone --recurse-submodules https://github.com/go-plot/docs.git cd docs -mkdir -p data && sh themes/hextra/scripts/page-history.sh > data/pagehistory.json +mkdir -p data && go run github.com/tannevaled/hextra/cmd/pagehistory@v0.21.0 > data/pagehistory.json hugo server --baseURL http://localhost:1313/docs/0.3/ ``` diff --git a/assets/css/custom.css b/assets/css/custom.css index 7ed8118..bb7a561 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -31,7 +31,6 @@ /* The version selector's list hangs from its button's right edge, so that it * stays on screen at the end of the navbar. */ -.fs-version-select .hextra-nav-menu-items { left: auto !important; right: 0; transform: none !important; } /* The outdated-version banner (layouts/_partials/custom/content-begin.html). */ .nd-outdated { margin-top: 1rem; padding: 0.75rem 1rem; border-radius: 0.5rem; diff --git a/hugo.yaml b/hugo.yaml index bdddef4..2b08102 100644 --- a/hugo.yaml +++ b/hugo.yaml @@ -67,7 +67,7 @@ menu: weight: 3 params: type: partial - partial: custom/version-select.html + partial: components/version-select.html - name: Theme weight: 4 params: @@ -140,7 +140,7 @@ params: displayDescription: true # "Created on ... by ... ยท Modified on ... by ..." at the foot of each page: # creation from data/pagehistory.json, which the build writes with - # themes/hextra/scripts/page-history.sh (it needs the full git history); + # the theme's cmd/pagehistory (it needs the full git history); # modification from git (enableGitInfo). history: true contextMenu: diff --git a/layouts/_partials/custom/version-select.html b/layouts/_partials/custom/version-select.html deleted file mode 100644 index 6d08a2a..0000000 --- a/layouts/_partials/custom/version-select.html +++ /dev/null @@ -1,118 +0,0 @@ -{{- /* Navbar version selector, as in go-fileshare/docs and claimward/docs. - - Each documentation version is a separate build published under - //, where is the minor version of go-plot/plot the - pages describe (0.1, ...), or "main" until the first release, and its - baseURL ends with that version. A build cannot know the versions published - after it, so the server renders only the current one; in the browser the - list is filled from /versions.json, which the deploy job rewrites - in the format mike writes (version, title, aliases, properties). - - The site is ready for several languages: English at the root of a version, - the others under their code (/fr/...). Each option opens, in that - version, the first of these that exists: the current page in the current - language; the same page in English; the home in the current language; the - version's home. A page that a version does not have therefore never ends on - a 404. The language prefix is read from the home's permalink, not guessed - from the URL. - - Built on Hextra's own navbar dropdown (assets/js/core/nav-menu.js), so its - keyboard handling applies. */ -}} -{{- $page := . -}} -{{- $basePath := strings.TrimSuffix "/" (urls.Parse site.BaseURL).Path -}} -{{- $current := path.Base $basePath -}} -{{- $docsRoot := printf "%s/" (strings.TrimSuffix "/" (path.Dir $basePath)) -}} -{{- $versionRoot := printf "%s%s/" $docsRoot $current -}} -{{- $rest := strings.TrimPrefix $versionRoot $page.RelPermalink -}} -{{- /* "fr/" in French, "" in English (the default language, at the root). */ -}} -{{- $langPrefix := strings.TrimPrefix $versionRoot site.Home.RelPermalink -}} -{{- /* The same page in the default language: same file names in every content//. */ -}} -{{- $restDefault := cond (ne $langPrefix "") (strings.TrimPrefix $langPrefix $rest) $rest -}} -{{- $dev := site.Params.versions.development | default "dev" -}} -{{- $itemClass := "hx:text-gray-600 hx:hover:text-gray-800 hx:dark:text-gray-400 hx:dark:hover:text-gray-200 hx:relative hx:cursor-pointer hx:whitespace-nowrap hx:rounded-sm hx:py-1.5 hx:transition-colors hx:ltr:pl-3 hx:ltr:pr-9 hx:rtl:pr-3 hx:rtl:pl-9 hx:flex hx:items-center hx:gap-1 hx:hover:bg-gray-100 hx:dark:hover:bg-neutral-800" -}} -{{- $iconAttrs := `height="1em" class="hx:inline-block"` -}} -
- - - - - -
- diff --git a/themes/hextra b/themes/hextra index 1d8daa4..8069144 160000 --- a/themes/hextra +++ b/themes/hextra @@ -1 +1 @@ -Subproject commit 1d8daa42d0406250fa00b7e803db2ab104a7fcab +Subproject commit 80691446c55a4c70c3c11dca3d1b464148d6b438