Add a page search to the top of the left menu#1029
Closed
MDA2AV wants to merge 1 commit into
Closed
Conversation
Closes #970. The Hextra theme's search went away with Hugo, and with it the only way to find a test specification by name: the board's existing search box filters framework rows, so a query like "prior-knowledge" or "MTU" matched nothing anywhere on the site. 124 Knowledge Base pages were reachable only by walking the tree. Search covers the Knowledge Base by title AND full body text, plus every leaderboard destination (28 profile views and the 6 composite scopes), so "h2c" reaches both the JSON (h2c) board and its implementation page. Results are ranked: a title hit outranks a body hit, an exact title match wins outright, and views float slightly above docs since they are the cheaper landing. Multi-word queries are AND (every term must appear somewhere), each doc hit carries a breadcrumb and a snippet with the match highlighted, and the list caps at 25. No dependency and no index file. docs.js already ships every page's rendered HTML, so the index is built from what is already in memory, on the first keystroke rather than at load -- 158 entries over 0.24 MB of text in ~5 ms. Tags are stripped with a regex rather than by assigning to a detached innerHTML, because that would fetch any <img> the docs grow later. Two structural details: buildNav() now clears #navTree instead of #nav. The search box is static markup above it, so it survives the nav rebuild that every navigation triggers -- otherwise typing would lose focus as soon as results changed. On mobile the tree is still hidden in favour of the existing select, but .nav is no longer display:none, so the search bar itself stays reachable. Keyboard: arrows move the selection, Enter opens, Escape clears. Opening a result clears the query first, so the user lands on a normal menu showing where they now are. Colours come from the existing theme variables, so light and dark both work. Verified end-to-end in headless Chrome against the real data files: the tree builds into its new container, typing "fortunes" yields 6 hits with the tree hidden and the first hit selected, ArrowDown moves the selection, clicking a docs hit renders the page and rewrites the URL to #doc=test-profiles/h1/isolated/fortunes (so results stay deep-linkable), the input clears and the tree comes back, a nonsense query shows the empty state, and Escape restores everything. Checked at 1400px and 400px.
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #970.
The Hextra theme's search went away with Hugo, and with it the only way to find a test specification by name. The board's existing search box filters framework rows, so a query like
prior-knowledgeorMTUmatched nothing anywhere on the site — and 124 Knowledge Base pages were reachable only by walking the tree.What it searches
MTUfinds the setup page andprior-knowledgefinds the H/2 validation docs.h2creaches both the JSON (h2c) board and its implementation page.Results are ranked (title hit > body hit, exact title match wins outright, views float slightly above docs since they're the cheaper landing). Multi-word queries are AND. Each docs hit carries a breadcrumb and a snippet with the match highlighted. Capped at 25.
No dependency, no index file
docs.jsalready ships every page's rendered HTML, so the index is built from what's already in memory — 158 entries over 0.24 MB of text in ~5 ms, on the first keystroke rather than at load. Tags are stripped with a regex rather than by assigning to a detachedinnerHTML, which would fetch any<img>the docs grow later.Two structural details
buildNav()now clears#navTree, not#nav. The search box is static markup above it, so it survives the nav rebuild that every navigation triggers — otherwise typing would lose focus the moment results changed.<select>, but.navis no longerdisplay:none, so the search bar stays reachable.Keyboard: arrows move the selection, Enter opens, Escape clears. Opening a result clears the query first, so you land on a normal menu showing where you now are. Colours come from the existing theme variables — light and dark both work.
Verified end-to-end in headless Chrome against the real data files
fortunes→ hits, tree hidden, first selected#doc=test-profiles/h1/isolated/fortunes✓Possible follow-up, deliberately left out to keep this scoped: a
/orCtrl-Kshortcut to focus the box.🤖 Generated with Claude Code