import Image from "next/image"; import { getTranslations } from "next-intl/server"; import Link from "@/components/link"; import { ContentCard, EmptyState } from "@/components/public/ui"; import { excerpt } from "@/lib/format"; import { formatDate } from "@/lib/format-date"; import { logger } from "@/lib/logger"; import { withPublicPagePerformance } from "@/lib/public-page-performance"; import { loadNewsArchive } from "@/lib/services/news-archive"; export const metadata = { title: "News" }; async function NewsPage({ searchParams, }: { searchParams: Promise<{ q?: string; page?: string; order?: string }>; }) { const t = await getTranslations("pages.news"); const params = await searchParams; const result = await loadNewsArchive({ search: params.q, page: Number(params.page ?? 1), order: params.order, }).catch((error) => { logger.error("Public news archive failed", { module: "news", error }); return null; }); const articles = result?.rows ?? []; const href = (page: number) => `/news?${new URLSearchParams({ q: result?.search ?? params.q ?? "", order: result?.order ?? "newest", page: String(page) })}`; return (
{!result ? (

{t("loadError")}

) : articles.length === 0 ? ( {t("noArticles")} ) : (
{articles.map((a) => ( {a.image ? (
) : (
)}

{a.title}

{formatDate(a.createdAt, "date", "")}

{excerpt(a.shortStory, 150)}

))}
)} {result && ( )}
); } export default withPublicPagePerformance("/news", NewsPage);