import { getTranslations } from "next-intl/server"; import Link from "next/link"; import { ContentCard, EmptyState } from "@/components/public/ui"; import { excerpt } from "@/lib/format"; import { prisma } from "@/lib/prisma"; export const revalidate = 300; export const metadata = { title: "News" }; function formatDate(d: Date | null): string { return d ? d.toISOString().slice(0, 10) : ""; } export default async function NewsPage() { const t = await getTranslations("pages.news"); let articles: Awaited> = []; try { articles = await prisma.websiteArticles.findMany({ orderBy: { createdAt: "desc" }, take: 30, }); } catch { // DB unavailable — render the empty state rather than a 500. articles = []; } return (
{articles.length === 0 ? ( {t("noArticles")} ) : (
{articles.map((a) => (
📰 {t("title")} · {formatDate(a.createdAt)}
{a.image ? ( ) : (
)}

{a.title}

{excerpt(a.shortStory, 200)}

))}
)}
); }