Skip to content

Add /search page backed by Google Programmable Search#328

Open
Blargian wants to merge 1 commit into
mainfrom
search-page
Open

Add /search page backed by Google Programmable Search#328
Blargian wants to merge 1 commit into
mainfrom
search-page

Conversation

@Blargian

@Blargian Blargian commented Jul 3, 2026

Copy link
Copy Markdown
Member

What

Adds an unlisted /search page (search.mdx, deliberately omitted from navigation.json — reachable by URL, not shown in the sidebar) that renders our own search box plus a Google Programmable Search (CSE) results-only element, driven via the CSE API.

This mirrors the kubernetes.io/search approach and gives us:

  • Full styling control of the box (it's our own <input>, styled to match the sidebar search) — no fighting Google's nested-table DOM.
  • Clean URLs?q=test instead of the combined widget's #gsc.tab=0&gsc.q=… hash.

How

  • Loader runs in parsetags: 'explicit'; the results element is rendered imperatively into a ref'd container.
  • The results container is stashed on window and re-attached on mount so it survives MDX remounts (e.g. a theme toggle would otherwise wipe Google's injected DOM).
  • ?q= is the source of truth: submit does pushState; popstate (back/forward) re-runs the query in place, with dedup so an unchanged param updates rather than destroys the results.
  • Custom .ch-cse* styling (box + "Enter ↵" keycap) and .gsc*/.gs* result styling (titles, breadcrumbs, snippets, pagination, "Search … on Google") for light and dark, overriding the aggressive .prose link rules.

Verification

Verified in real Chrome (light + dark): load ?q=… auto-runs, typed submit + Enter keycap work, back/forward updates results in place, and results persist across a theme toggle.

🤖 Generated with Claude Code

Adds an unlisted /search page (search.mdx, omitted from navigation.json)
that renders a custom, sidebar-styled search box plus a Google CSE
'searchresults-only' element, driven via the CSE API. This keeps full
control of the box styling and the URL (clean ?q=… instead of the widget's
#gsc.* hash), matching the kubernetes.io/search approach.

Details:
- Results-only mode + our own input; queries run via element.execute().
- Results container is stashed on window and re-attached on mount so it
  survives MDX remounts (e.g. theme toggle).
- ?q= is the source of truth: submit pushes history, popstate re-runs the
  query in place (dedup avoids destroying results on an unchanged param).
- Custom .ch-cse* styling to match the sidebar search + an Enter keycap;
  .gsc*/.gs* result styling (titles, breadcrumbs, snippets, pagination) for
  light and dark, overriding the prose link rules.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mintlify

mintlify Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
ClickHouse-docs 🟢 Ready View Preview Jul 3, 2026, 10:32 PM

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1adf921. Configure here.

Comment thread search.mdx
if (inputRef.current && inputRef.current.value !== q) inputRef.current.value = q;
if (q === lastQRef.current) return;
lastQRef.current = q;
if (q) execute(q);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty query leaves stale results

Medium Severity

The runQuery function's if (q) execute(q) check prevents clearing Google search results when the query becomes empty. This leaves stale results visible even though the input and URL reflect no active search.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1adf921. Configure here.

Comment thread search.mdx
attributes: { enableHistory: false },
});
}
runQuery(initial);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boot uses stale URL query

High Severity

The boot function initializes search with a stale initial query value, captured at mount. If the URL's ?q parameter changes before the Google CSE script loads, the deferred boot uses the old query, causing the search input and results to mismatch the current URL.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1adf921. Configure here.

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