From eea13b0ff2aa1a8e39df6700962b38d10825b244 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Wed, 3 Dec 2025 08:37:51 +0100 Subject: [PATCH] Color the currently selected version in the picker Signed-off-by: Johannes Marbach --- assets/js/versions.template.js | 15 +++++++++++++++ assets/scss/_styles_project.scss | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/assets/js/versions.template.js b/assets/js/versions.template.js index ab66309e..0083a7fd 100644 --- a/assets/js/versions.template.js +++ b/assets/js/versions.template.js @@ -14,9 +14,24 @@ See the License for the specific language governing permissions and limitations under the License. */ +// This oddity is an attempt at producing a readable Hugo template while avoiding +// JS syntax errors in your IDE +const currentVersion = `{{ if eq .Site.Params.version.status "unstable" }} + {{- /**/ -}} + unstable + {{- /**/ -}} +{{ else }} + {{- /**/ -}} + {{ printf "v%s.%s" .Site.Params.version.major .Site.Params.version.minor }} + {{- /**/ -}} +{{ end }}`; + function appendVersion(parent, name, url) { // The list item const li = document.createElement("li"); + if (name === currentVersion) { + li.classList.add("selected") + } parent.appendChild(li); // The link diff --git a/assets/scss/_styles_project.scss b/assets/scss/_styles_project.scss index 9739f239..62952bd3 100644 --- a/assets/scss/_styles_project.scss +++ b/assets/scss/_styles_project.scss @@ -50,6 +50,10 @@ Custom SCSS for the Matrix spec a { color: $black; } + + ul#version-selector li.selected a { + color: $secondary; + } } /* Styles for the sidebar nav */