Add version picker in the navbar

Fixes: #951
Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
This commit is contained in:
Johannes Marbach 2025-12-01 08:27:32 +01:00
parent b1fd2af72c
commit dc0ee1a49a
3 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1 @@
Add version picker in the navbar.

View file

@ -78,6 +78,10 @@ current_version_url = "https://spec.matrix.org/latest"
# major = "1"
# minor = "16"
[[params.versions]]
# We must include this parameter to enable docsy's version picker in the navbar. The picker
# is populated automatically in navbar-version-selector.html.
# User interface configuration
[params.ui]
# Collapse HTTP API and event <details> elements

View file

@ -0,0 +1,28 @@
{{- /*
A version of the navbar-version-selector.html partial in Docsy,
modified to read the versions from changelog child pages so that
we don't have to maintain the menu separately in hugo.toml.
*/ -}}
{{ $changelog := site.GetPage "changelog" }}
{{ $pages := $changelog.RegularPages.ByDate.Reverse }}
<div class="dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
All Versions
</a>
<ul class="dropdown-menu">
{{- /* Prepend a link to the unstable spec version */ -}}
<li><a class="dropdown-item" href="https://spec.matrix.org/unstable">Unstable</a></li>
{{- /* Add a link for each vX.X version */ -}}
{{ range $pages }}
{{ if findRE `^v[0-9]+\.[0-9]+$` .Params.linkTitle }}
<li><a class="dropdown-item" href="https://spec.matrix.org/{{ .Params.linkTitle }}">{{ .Params.linkTitle }}</a></li>
{{ end }}
{{ end }}
{{- /* Append a link to historical spec versions in the changelog */ -}}
<li><a class="dropdown-item" href="/changelog/historical/">Historical</a></li>
</ul>
</div>