Skip to content

Migrate search to Pagefind Component UI#71

Merged
jdevalk merged 1 commit into
mainfrom
search-component-ui
Jun 30, 2026
Merged

Migrate search to Pagefind Component UI#71
jdevalk merged 1 commit into
mainfrom
search-component-ui

Conversation

@jdevalk

@jdevalk jdevalk commented Jun 30, 2026

Copy link
Copy Markdown
Owner

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

  • Lazy-loaded component bundle on first open (~46 kB stays off visitors who never search). External module, no inline JS — strict CSP unchanged.
  • Full-fidelity Plausible analytics preserved via the component's typed event API (search/results), reading the exact result count instead of scraping the DOM.
  • Shortcuts — our own global ⌘K + / handlers retained; the component owns the modal, focus, ARIA combobox and arrow-key navigation.
  • Theming--pf-* mapped to our design tokens on html[lang] (outranks the component's :root defaults regardless of load order); color-scheme: inherit forced past the component's host reset so light-dark() flips correctly. Verified in light and dark.
  • Polish — accent-pill highlights on matched terms, excerpt-length 30 with multi-line wrapping.
  • WebMCP open_search tool repointed at the new modal driver.
  • Removed search-overlay.js / search-init.js; added search.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 changed entry 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

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>
@jdevalk jdevalk merged commit c1f7f89 into main Jun 30, 2026
8 checks passed
@jdevalk jdevalk deleted the search-component-ui branch June 30, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant