web: highlight word matches, limit search results

This commit is contained in:
2026-05-25 23:39:11 +02:00
parent 2c8f8a218c
commit 1b5483602f
4 changed files with 82 additions and 11 deletions
+12 -2
View File
@@ -17,6 +17,8 @@ export default async function Page({
}) {
const { q: query } = (await searchParams) ?? {};
let results: SearchResult[] = [];
let totalCount = 0;
const RESULT_LIMIT = 500;
if (query) {
const searchQuery = graphql(`
@@ -64,13 +66,21 @@ export default async function Page({
`);
const { data } = await getClient().query(searchQuery, { query });
results = (data?.results ?? []) as SearchResult[];
const all = (data?.results ?? []) as SearchResult[];
totalCount = all.length;
results = all.slice(0, RESULT_LIMIT);
}
return (
<main className="site-main" id="main">
<SearchShell initialQuery={query ?? ""}>
{query ? <SearchResults results={results} /> : null}
{query ? (
<SearchResults
results={results}
totalCount={totalCount}
query={query}
/>
) : null}
</SearchShell>
</main>
);