matrix-spec/layouts/_partials/navbar-version-selector.html
Johannes Marbach dc0ee1a49a Add version picker in the navbar
Fixes: #951
Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
2025-12-01 08:57:18 +01:00

29 lines
1.2 KiB
HTML

{{- /*
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>