From 1d439a7c835d4ad2c5ab6a6fbcae5ce65d46d746 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 1 Oct 2026 01:20:44 +0000 Subject: [PATCH] chore: publish from main --- website/src/components/brand/TopNavSearch.tsx | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/website/src/components/brand/TopNavSearch.tsx b/website/src/components/brand/TopNavSearch.tsx index 8e9466801..3b637ad45 100644 --- a/website/src/components/brand/TopNavSearch.tsx +++ b/website/src/components/brand/TopNavSearch.tsx @@ -29,6 +29,12 @@ const MAX_PER_GROUP = 4; const MAX_PAGEFIND_HITS = 12; type ResultGroup = { category: SearchCategory; items: SearchItem[] }; +type NormalizedSearchItem = { + item: SearchItem; + title: string; + description: string; + category: string; +}; /** * Shared top-navigation search. A collapsed magnifier button expands into a @@ -120,15 +126,28 @@ export function TopNavSearch({ }; }, [trimmed]); + const normalizedIndex = useMemo( + () => + index.map((item) => ({ + item, + title: item.title.toLowerCase(), + description: item.description.toLowerCase(), + category: item.category.toLowerCase(), + })), + [index], + ); + const groups = useMemo(() => { const query = trimmed.toLowerCase(); if (query.length === 0) return []; - const staticMatches = index.filter( - (item) => - item.title.toLowerCase().includes(query) || - item.description.toLowerCase().includes(query) || - item.category.toLowerCase().includes(query), - ); + const staticMatches = normalizedIndex + .filter( + ({ title, description, category }) => + title.includes(query) || + description.includes(query) || + category.includes(query), + ) + .map(({ item }) => item); // Static hits win on ties: they carry curated titles and descriptions. const seen = new Set(staticMatches.map((item) => hrefKey(item.href))); const matches = [...staticMatches]; @@ -150,7 +169,7 @@ export function TopNavSearch({ grouped.push({ category, items }); } return grouped; - }, [trimmed, index, pagefindHits]); + }, [trimmed, normalizedIndex, pagefindHits]); const flatResults = useMemo( () => groups.flatMap((group) => group.items),