import Image from "next/image"; import Link from "next/link"; import { getTranslations } from "next-intl/server"; 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) => ( {a.image ? (
) : (
)}

{a.title}

{formatDate(a.createdAt)}

{excerpt(a.shortStory, 150)}

))}
)}
); }