Migrate search to Pagefind Component UI#71
Merged
Merged
Conversation
Replace the hand-rolled <dialog> + Default UI search with Pagefind's Component UI for both the global ⌘K modal and the /search/ page, plus a mobile search button in the header. - Lazy-load the component bundle on first open to keep ~46 kB off visitors who never search; CSP-safe (external module, no inline JS). - Preserve full-fidelity Plausible analytics via the component's typed event API (search/results), reading the exact result count instead of scraping the rendered DOM. - Keep our own global ⌘K and "/" shortcuts; the component owns the modal, focus, ARIA combobox and keyboard navigation. - Theme the widget to our design tokens in light and dark: map --pf-* on html[lang] to outrank the component's :root defaults, and force color-scheme: inherit past its host reset so light-dark() flips. - Style matched terms with an accent pill and set excerpt length to 30 with multi-line wrapping for more context. - Point the WebMCP open_search tool at the new modal driver. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Replaces the hand-rolled
<dialog>+ Pagefind Default UI search with Pagefind's Component UI for both the global ⌘K modal and the/search/page, and adds a search button to the mobile header.Why
Pagefind recommends the Component UI for new integrations (better accessibility, a real modal). This swap keeps our search current and improves keyboard/ARIA behaviour, while staying CSP-safe and cookie-free.
Highlights
search/results), reading the exact result count instead of scraping the DOM./handlers retained; the component owns the modal, focus, ARIA combobox and arrow-key navigation.--pf-*mapped to our design tokens onhtml[lang](outranks the component's:rootdefaults regardless of load order);color-scheme: inheritforced past the component's host reset solight-dark()flips correctly. Verified in light and dark.excerpt-length30 with multi-line wrapping.open_searchtool repointed at the new modal driver.search-overlay.js/search-init.js; addedsearch.js/search-page.js.Verification
Built and driven in a real browser (Chrome DevTools): modal lazy-loads and opens, returns results, analytics event fires with
{term, results, found, surface},/search/prefills from?q=, and theming flips correctly in both modes.astro check, eslint, and prettier all pass.Changelog
Includes a
changedentry for the search rebuild. Note: this is the changelog's first plumbing entry (it maps to no spec page) — drop it if you'd rather keep/changelog/purely about spec content.🤖 Generated with Claude Code