import { desc } from "drizzle-orm"; import Image from "next/image"; import Link from "next/link"; import { getTranslations } from "next-intl/server"; import { ContentCard, EmptyState } from "@/components/public/ui"; import { db, WebsiteArticles } from "@/lib/db"; import { excerpt } from "@/lib/format"; import { formatDate } from "@/lib/format-date"; // TODO: Cache Components adoption. Refactor this route so this opt-out can be removed. // See: https://nextjs.org/docs/app/guides/migrating-to-cache-components export const instant = false; export const metadata = { title: "News" }; export default async function NewsPage() { const t = await getTranslations("pages.news"); let articles: (typeof WebsiteArticles.$inferSelect)[] = []; try { articles = await db .select() .from(WebsiteArticles) .orderBy(desc(WebsiteArticles.createdAt)) .limit(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, "date", "")}

{excerpt(a.shortStory, 150)}

))}
)}
); }