Add a search bar to the documentation site - #236
Open
jiheunha wants to merge 11 commits into
Open
Conversation
added 11 commits
May 20, 2026 11:54
The official documentation site currently has no search functionality, making it difficult to find specific content across 43+ pages. This adds a lightweight, zero-dependency search feature: - search.json: Jekyll-generated index of all page titles and content - javascripts/search.js: client-side search with snippet previews - Search input in the sidebar header with a dropdown results overlay Works entirely client-side on GitHub Pages — no server or plugins needed.
- Use Jekyll's relative_url filter to compute the search.json path so it works regardless of whether baseurl is set in _config.yml - Move the search box inline with the navigation row, on the right side
- Pre-filter pages with where_exp so the loop only iterates valid entries, eliminating the trailing comma that broke JSON parsing - Add Enter key handler and a Search button next to the input
- Always show overlay during search (loading + error feedback)
- Tighten event handling (closest('.gcam-search-box') for outside-click)
- Defensive: also set overlay.style.display explicitly
- Higher z-index so overlay isn't clipped by surrounding chrome
Temporary — remove before merging.
- Force display/visibility/opacity in inline style - Add !important on overlay CSS and log rect to find clipping
The site's existing CSS targets every <ul> inside <header> with absolute positioning and a fixed 38px height (for the Download/View-on-GitHub button group), which collapsed the search results list to ~3px tall. This adds specific overrides for the search overlay and result list so it renders as a normal dropdown. Also polishes the result item design. Removes temporary console.log debugging.
Result links now carry ?q=<query>; on page load the script walks the content tree, wraps every occurrence in a <mark>, scrolls the first one into view, and prefills the search box so the query is editable. The first match is highlighted in orange and given a subtle outline so it stands out from the other yellow highlights on the page.
Pages from archived versions (v3.2, v4.2, ...) share titles with the
current docs, so the result list was full of look-alike duplicates. Each
result now carries a small version badge ("current" for the latest docs,
or e.g. "v3.2" for archived pages) so they're easy to tell apart.
Pages from the current docs don't need a badge; they're the default. Only archived /vX.Y/ pages now carry a version chip like "v3.2".
Pages from the latest docs (no /vX.Y/ in the URL) now sort to the top of the result list; archived versions follow. Within each group, results are still ordered by match count.
jiheunha
force-pushed
the
feature/add-search
branch
from
May 20, 2026 02:54
b2cb673 to
bf5c223
Compare
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.
Hi, thank you for maintaining such thorough documentation for GCAM. It has been a huge help.
One thing I kept running into is that the docs site has no search box, so finding a specific function or explanation usually meant visiting many pages. This PR adds a search bar to make that easier.
Summary
vX.Y) are labeled with a version badge and sorted below current docs so they do not get in the way.I built this on my fork so you can see how it works: https://jiheunha.github.io/gcam-doc/
Thank you!