P0-3/4/5: route error boundary, null guards, slug fallback, search
P0-3 (category page crash):
- Add src/app/error.tsx and src/app/global-error.tsx so any future render
error shows a real ref id instead of the bare client-exception toast.
- NewsPageClient: null-guard every field accessed during search/category/
sort filtering and article render (title, excerpt, author, tags,
category, date, image, alt). The user-visible link
/news?category=live-production now also hydrates filter state from
?category= and ?search= search-params, so the dropdown actually filters.
P0-4 (/articles/[slug] 404s):
- /articles/[slug] and /news/[slug]: on slug miss, redirect("/news")
instead of notFound(). Dead links from the hardcoded NewsTicker /
FeaturedBento / ArticleFeed arrays now land on the news index instead
of dead-ending on 404.
- legacy-source: add searchLegacyArticles() (title/excerpt/author ilike).
P0-5 (header search):
- Header: wire Enter on the desktop and mobile search inputs and make
both search icons clickable buttons. Submits to /search?q=<query>.
- New /search route: server component that runs searchLegacyArticles
and renders results in the same card style as /news.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -170,6 +170,28 @@ export async function getLegacyArticlesBySection(
|
||||
}
|
||||
}
|
||||
|
||||
export async function searchLegacyArticles(
|
||||
query: string,
|
||||
limit = 50,
|
||||
): Promise<Article[]> {
|
||||
const q = (query || "").trim();
|
||||
if (!q) return [];
|
||||
try {
|
||||
const like = `%${q.replace(/[%_]/g, " ")}%`;
|
||||
const { data, error } = await client()
|
||||
.from("wp_imported_posts")
|
||||
.select(SELECT_COLS)
|
||||
.eq("status", "published")
|
||||
.or(`title.ilike.${like},excerpt.ilike.${like},author_name.ilike.${like}`)
|
||||
.order("wp_published_at", { ascending: false })
|
||||
.limit(limit);
|
||||
if (error || !data) return [];
|
||||
return (data as ImportedPostRow[]).map((r) => rowToArticle(r, "news"));
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export async function getLegacyRecentSlugs(limit = 200): Promise<string[]> {
|
||||
try {
|
||||
const { data } = await client()
|
||||
|
||||
Reference in New Issue
Block a user