diff --git a/sass/_valkey.scss b/sass/_valkey.scss index 4c59ffb8..a19feb4a 100644 --- a/sass/_valkey.scss +++ b/sass/_valkey.scss @@ -1462,6 +1462,12 @@ pre table { } } +.category-link.active, +.show-all-link.active { + font-weight: 700; + color: $link-color; +} + .index-entry { padding: 0.5em 1em; margin-bottom: 0.5em; diff --git a/templates/commands.html b/templates/commands.html index 9736970b..f9c8b26f 100644 --- a/templates/commands.html +++ b/templates/commands.html @@ -92,11 +92,70 @@

{{ group_descriptions[command_group_ // Show/hide no results message based on search results noResultsMessage.style.display = totalVisible === 0 ? "block" : "none"; } + +function filterByCategory() { + var hash = window.location.hash.substring(1); + var groups = document.querySelectorAll(".command-group"); + var sidebarLinks = document.querySelectorAll(".category-link"); + var noResultsMessage = document.getElementById("no-results-message"); + + // Clear search box when filtering by category + var searchBox = document.getElementById("search-box"); + if (searchBox) searchBox.value = ""; + + // Update active state on sidebar links + sidebarLinks.forEach(function (link) { + link.classList.remove("active"); + if (link.getAttribute("href") === "#" + hash) { + link.classList.add("active"); + } + }); + + // If no hash or hash is "top", show all groups + if (!hash || hash === "top") { + groups.forEach(function (group) { + group.style.display = ""; + group.querySelectorAll(".command-entry").forEach(function (item) { + item.style.display = ""; + }); + }); + noResultsMessage.style.display = "none"; + sidebarLinks.forEach(function (link) { link.classList.remove("active"); }); + var showAllLink = document.querySelector(".show-all-link"); + if (showAllLink) showAllLink.classList.add("active"); + return; + } + + // Show only the matching group + var found = false; + groups.forEach(function (group) { + var heading = group.querySelector("h2"); + if (heading && heading.id === hash) { + group.style.display = ""; + group.querySelectorAll(".command-entry").forEach(function (item) { + item.style.display = ""; + }); + found = true; + } else { + group.style.display = "none"; + } + }); + + noResultsMessage.style.display = found ? "none" : "block"; +} {% endblock main_content %} @@ -104,10 +163,11 @@

{{ group_descriptions[command_group_ {% block related_content %}

Command Categories