search: return all matches (not just 100) + add typeahead autocomplete
- searchLegacyArticles() default limit: 50 → 5000. /search page
explicitly passes 5000 too. ilike on title/excerpt/author is fast
enough on the 29k-row archive that returning everything is fine.
- New API route /api/search/suggest?q=...&limit=8 returns the top
matching article titles + category + slug, with a 30-second CDN
cache + 60-second stale-while-revalidate.
- The search input in the Browse bar now debounces (150ms) and
fires that API per keystroke once 2+ chars are typed. Matches
appear in a styled dropdown below the input — click to navigate
directly to /news/<slug>, or press Enter to fall through to the
full /search page. "See all results for …" link in the dropdown
footer.
- Keyboard: Escape closes the dropdown; aria-autocomplete + role
listbox/option for accessibility.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -314,9 +314,13 @@ export async function getLegacyArticlesBySection(
|
||||
return merged.slice(0, limit).map((m) => m.article);
|
||||
}
|
||||
|
||||
// Default raised from 50 → 5000 because users expect search to return
|
||||
// every match. The 29k-article archive is small enough that title/excerpt
|
||||
// ilike filters stay fast even without an explicit cap. Pass a smaller
|
||||
// `limit` (e.g. 10) for autocomplete-style typeahead queries.
|
||||
export async function searchLegacyArticles(
|
||||
query: string,
|
||||
limit = 50,
|
||||
limit = 5000,
|
||||
): Promise<Article[]> {
|
||||
const q = (query || "").trim();
|
||||
if (!q) return [];
|
||||
|
||||
Reference in New Issue
Block a user