import { desc } from "drizzle-orm"; import Link from "next/link"; import { getTranslations } from "next-intl/server"; import { ContentCard, EmptyState } from "@/components/public/ui"; import { db, Guilds } from "@/lib/db"; import { excerpt } from "@/lib/format"; // 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: "Guilds" }; type GuildCard = { id: number; name: string; description: string; badge: string; }; async function getGuilds(): Promise { try { return await db .select({ id: Guilds.id, name: Guilds.name, description: Guilds.description, badge: Guilds.badge, }) .from(Guilds) .orderBy(desc(Guilds.id)) .limit(40); } catch { return []; } } export default async function GuildsPage() { const t = await getTranslations("pages.guilds"); const guilds = await getGuilds(); return (
{guilds.length === 0 ? ( {t("empty")} ) : (
{guilds.map((g) => ( {g.badge ? ( // eslint-disable-next-line @next/next/no-img-element {`${g.name} ) : null}

{g.name || t("unnamedGuild")}

{g.description ? excerpt(g.description, 120) : t("noDescription")}

))}
)}
); }