Skip to content
This repository was archived by the owner on Nov 30, 2026. It is now read-only.

Context-aware docs search with section badges, sub-results, and direct URLs - #184

Merged
Urigo merged 4 commits into
mainfrom
search-and-polish
Sep 2, 2026
Merged

Urigo merged 4 commits into
mainfrom
search-and-polish

Conversation

@Urigo

@Urigo Urigo commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

What

Implements the search feedback from the Slack thread (@dotansimha's "big gap": no breadcrumbs/context, not context-aware, dark-mode blink on result click) plus the remaining production nice-to-haves.

Search (the thread)

  • Section badge on every result — each docs page is tagged with its product section (Router / Gateway / Console) as a pagefind filter + metadata; result titles render as Usage Reporting · Router
  • Context-aware — the modal defaults the section filter to the section being browsed: searching from a Router page returns Router results. A section dropdown in the modal header (pagefind's own filter component) is the "other 1%" escape hatch back to all docs
  • Heading context — show-sub-results lists matching headings beneath each page result (up to 3)
  • No blog results — already the case (only docs pages carry data-pagefind-body), now guaranteed to stay that way since search is filter-scoped to docs sections
  • Dark-mode blink — result links previously pointed at …/page/ and ate a 301 redirect on every click, which is the main white flash between pages. A url metadata override makes results (and sub-result anchors) link the canonical slash-less URL directly — no hop. ThemeInit already sets color-scheme inline before paint, covering the rest

Dark-mode modal, verified headlessly (Router page, query "usage" — note the active section ⓵ filter chip, badges, and sub-results):

  • Composed modal renders in both themes with zero console errors
  • Router-page search returns only Router results; the dropdown widens scope
  • Result hrefs: /docs/router/observability/usage_reporting — no trailing slash

Nice-to-haves

  • Sitemap <lastmod> — derived per page from the git history of content files in one pass (439 of 559 URLs; pages without a content file simply omit it)
  • Trailing-slash search links: covered by the url metadata override above

Not in this PR (they live in the-guild-org/website): HSTS header and removing the stale /graphql/hive_astro router route — companion PR coming there.

Verification

ASTRO_BASE_PATH=/graphql/hive build passes the base-path verifier; plain preview build unchanged; typecheck green.

🤖 Generated with Claude Code

…t URLs

Implements the search feedback from the team thread plus remaining
production nice-to-haves:

- Every docs page is tagged with its product section (Router / Gateway /
  Console) as a pagefind filter and metadata; result titles carry the
  section badge ("Usage Reporting · Router")
- The search modal is now composed explicitly and defaults the section
  filter to the section being browsed — searching from a Router page
  returns Router results; a section dropdown in the modal header widens
  back to all docs. Blog content was already excluded (only docs pages
  carry data-pagefind-body)
- show-sub-results lists matching headings beneath each page for context
- A url metadata override makes result links point at the canonical
  slash-less URL, removing the 301 hop on every result click (also the
  main cause of the white blink when navigating from the dark-mode
  modal)
- sitemap.xml gains <lastmod> per page, derived from the git history of
  the content files in a single pass (439 of 559 URLs)

Verified headlessly against a served build: composed modal renders in
both themes with zero console errors, Router-page searches return only
Router results with the dropdown as the escape hatch, result hrefs have
no trailing slash, and the prefixed build passes the base-path verifier.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

@dotansimha

Copy link
Copy Markdown
Member

when you open the search and then click on Section, it's cut off:
image

some results appear twice, not sure why?
image

- The section dropdown menu was cut off: the pf-modal dialog clips
  overflow for its rounded corners, and with a short result list the
  menu extended past the dialog edge. Let the menu escape (important,
  since pagefind's stylesheet loads after the bundled CSS).
- "Duplicate" results were each page's own h1 emitted as its first
  sub-result. Search indexing is now scoped to the description and
  content only — the h1 stays outside (the explicit title metadata
  already names the page), and breadcrumbs / prev-next links no longer
  leak into excerpts either.
- Bonus surfaced by the review screenshot: "[!toc]" markers on deep
  headings rendered literally on pages and in search results — a remark
  plugin now strips them (the TOC already only lists depths 2-4).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Urigo

Urigo commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Both fixed in 51c429f (@dotansimha):

  1. Cut-off dropdown — the pf-modal dialog clips overflow for its rounded corners, so with a short result list the menu extended past the dialog edge. The menu can now escape the dialog (overflow: visible, !important since pagefind's stylesheet loads after the bundled CSS). Verified headlessly: the full Console/Gateway/Router list renders past the dialog edge with counts, current section pre-checked.

  2. Duplicated results — that was each page's own h1 emitted as its first sub-result (same title + same excerpt as the page result right above it). Search indexing is now scoped to the description + content only: the h1 stays outside data-pagefind-body (the explicit title metadata already names the page), which also keeps breadcrumbs and prev/next links out of excerpts. Verified: sub-results now start at the first real section heading.

Bonus your screenshot surfaced: [!toc] markers on deep headings (e.g. in the router plugin-system hooks page) were rendering literally on pages and in search results — a remark plugin now strips them (the TOC already only lists depths 2–4, so no behavior change there).

- pagefind's entire dark theme (result-loading skeletons included) is
  scoped to [data-pf-theme="dark"], which the site never set — so in
  dark mode the placeholders flashed white while results loaded.
  ThemeInit now keeps data-pf-theme in sync with the site theme, brand
  skeleton colors are defined for both themes, and the dark --pf-* brand
  overrides moved to html.dark so pagefind's later-loading dark defaults
  can't override them at equal specificity.
- The composed pagefind-modal-header element has no layout styling of
  its own, so the section dropdown trigger sat touching the search
  input. It's a flex column with a gap now.

Verified in both themes with delayed fragment responses to hold the
skeleton state: dark shows dark-grey placeholders, light shows brand
beige, and the header spacing matches in both.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Urigo

Urigo commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Both new reports fixed in the latest commit (@dotansimha):

  1. White blink on loading placeholders (dark mode) — root cause: pagefind's entire dark theme, skeletons included, is scoped to [data-pf-theme="dark"], which we never set — we'd only been overriding individual --pf-* vars, so the loading skeletons kept pagefind's light defaults. ThemeInit now syncs data-pf-theme with the site theme, skeletons get brand colors in both themes, and our dark --pf-* overrides moved to html.dark so pagefind's later-loading dark defaults can't clobber them. Verified with artificially delayed fragment responses to hold the skeleton state: dark-grey placeholders in dark, brand beige in light.

  2. Section trigger touching the search input — the composed pagefind-modal-header element ships with no layout styling at all, so its children collided. It's now a flex column with a proper gap; verified in both themes.

The modal header re-parents composed children into a
.pf-modal-header-content div that is portaled into a top-level dialog,
so ancestor selectors through pagefind-modal never matched — and
pagefind's stylesheet inflates specificity on these containers with an
:is(*, #\#) hack (three ID-level selectors), so equal-specificity
overrides lost too. The layout rule now targets the dialog-scoped class
with !important: the header stacks input and dropdown with a 12px gap,
clearing the input's box-shadow focus ring.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Urigo

Urigo commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Dropdown/input border overlap fixed in the latest commit — measured 12px of clear space between the input's focus ring and the section trigger now, verified visually in both themes.

It resisted three polite attempts first: the modal header re-parents composed children into a .pf-modal-header-content div that's portaled into a top-level dialog (so ancestor selectors through pagefind-modal never match), and pagefind's stylesheet inflates specificity on these containers with an :is(*, #\#) hack — three ID-level selectors per rule. The layout override now targets the dialog-scoped class with !important, same approach as the dropdown-clipping fix.

@Urigo
Urigo merged commit 026a05b into main Sep 2, 2026
9 checks passed
@Urigo
Urigo deleted the search-and-polish branch September 2, 2026 18:37

This branch was successfully deployed

3 active deployments
astro-preview — ac0ae8c1 Deployed Sep 2, 2026 by Urigo via astro-website-preview / deployment #797
preview — ac0ae8c1 Deployed Sep 2, 2026 by Urigo via website-preview / deployment #797
storybook-preview — ac0ae8c1 Deployed Sep 2, 2026 by Urigo via storybook-preview / deployment #797
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants