Repository Public
1import type { Metadata } from "next";2import Link from "next/link";3import { getLocale } from "@/i18n/server";4import { dict, fill } from "@/i18n/dict";5import { listTopics } from "@/server/sheets";67export const dynamic = "force-dynamic";8const T = dict({ title: ["Thèmes", "Topics"], lead: ["Les fiches classées par domaine.", "Sheets grouped by field."], count: ["{n} fiche(s)", "{n} sheet(s)"], empty: ["Aucun thème pour l’instant.", "No topic yet."] });9export async function generateMetadata(): Promise<Metadata> { const t = T(await getLocale()); return { title: t.title, description: t.lead, alternates: { canonical: "/topics" } }; }1011export default async function Topics() {12 const locale = await getLocale(); const t = T(locale);13 const topics = (await listTopics(locale)).filter((x) => x.count > 0);14 return (15 <div className="mx-auto max-w-[1240px] pt-10 safe-x">16 <h1 className="font-display text-4xl font-semibold tracking-tight sm:text-5xl">{t.title}</h1>17 <p className="mt-3 text-lg text-muted">{t.lead}</p>18 {topics.length === 0 ? <p className="card mt-8 px-5 py-12 text-center text-muted">{t.empty}</p> : (19 <ul className="mt-8 grid gap-4 sm:grid-cols-2 lg:grid-cols-3">20 {topics.map((tp) => (21 <li key={tp.slug}>22 <Link href={`/topics/${tp.slug}`} className="card block h-full p-5 hover:shadow-card">23 <span className="font-display text-xl font-semibold">{tp.name}</span>24 {tp.description && <span className="mt-1 block text-[0.9375rem] leading-relaxed text-muted">{tp.description}</span>}25 <span className="mt-3 block text-sm text-faint">{fill(t.count, { n: tp.count })}</span>26 </Link>27 </li>28 ))}29 </ul>30 )}31 </div>32 );33}34