Repository Public
1import Link from "next/link";2import { getLocale } from "@/i18n/server";3import { dict, fill } from "@/i18n/dict";4import { listPublished, listTopics } from "@/server/sheets";5import { SheetCard, SheetGrid } from "@/components/site/sheet-card";6import { Signature } from "@/components/brand";78export const dynamic = "force-dynamic";910const T = dict({11 eyebrow: ["Fiches scientifiques et techniques", "Scientific and technical sheets"],12 title: ["Une idée, une fiche. Rigoureuse, visuelle, interactive.", "One idea, one sheet. Rigorous, visual, interactive."],13 lead: ["Des explications vectorielles de l’IA, de l’économétrie, de la finance et de l’infrastructure : diagrammes lisibles, équations définies, simulations à manipuler, sources citées.",14 "Vector explanations of AI, econometrics, finance and infrastructure: readable diagrams, defined equations, simulations to play with, cited sources."],15 searchLabel: ["Chercher une fiche", "Search the sheets"], searchPlaceholder: ["Transformer, GARCH, RAG…", "Transformer, GARCH, RAG…"], searchButton: ["Chercher", "Search"],16 featured: ["En vedette", "Featured"], recent: ["Fiches récentes", "Recent sheets"], all: ["Toutes les fiches", "All sheets"], topics: ["Explorer par thème", "Browse by topic"],17 count: ["{n} fiche(s)", "{n} sheet(s)"], aboutTitle: ["Le projet", "The project"],18 about: ["Sheet publie des fiches gratuites, sans compte, conçues pour être comprises en quelques minutes et vérifiées : chaque fiche indique ses sources et la nature de ses données.",19 "Sheet publishes free sheets, no account needed, designed to be understood in minutes and checked: every sheet states its sources and the nature of its data."],20 aboutLink: ["À propos de l’auteur", "About the author"],21 empty: ["Les premières fiches arrivent bientôt.", "The first sheets are on their way."],22});2324export default async function Home() {25 const locale = await getLocale();26 const t = T(locale);27 const [featured, recent, topics] = await Promise.all([28 listPublished({ featured: true, limit: 3, offset: 0, uiLocale: locale }),29 listPublished({ limit: 9, offset: 0, uiLocale: locale }),30 listTopics(locale),31 ]);32 const usedTopics = topics.filter((x) => x.count > 0);33 return (34 <div className="mx-auto max-w-[1240px] safe-x">35 <section className="pb-10 pt-10 sm:pb-14 sm:pt-16">36 <p className="eyebrow">{t.eyebrow}</p>37 <h1 className="mt-3 max-w-[18ch] font-display text-[2.4rem] font-semibold leading-[1.05] tracking-tight sm:text-6xl">{t.title}</h1>38 <p className="mt-5 max-w-[62ch] text-lg leading-relaxed text-muted">{t.lead}</p>39 <form action="/search" role="search" className="mt-7 flex max-w-xl gap-2">40 <label htmlFor="home-q" className="sr-only">{t.searchLabel}</label>41 <input id="home-q" name="q" type="search" enterKeyHint="search" autoComplete="off" placeholder={t.searchPlaceholder} className="field" />42 <button className="btn btn-primary" type="submit">{t.searchButton}</button>43 </form>44 </section>4546 {featured.items.length > 0 && (47 <section aria-labelledby="h-featured" className="pb-12">48 <h2 id="h-featured" className="eyebrow mb-4">{t.featured}</h2>49 <div className="grid gap-5 lg:grid-cols-2">50 <div className="lg:col-span-2"><SheetCard sheet={featured.items[0]} locale={locale} large /></div>51 {featured.items.slice(1).map((s) => <SheetCard key={s.slug} sheet={s} locale={locale} />)}52 </div>53 </section>54 )}5556 <section aria-labelledby="h-recent" className="pb-12">57 <div className="mb-4 flex items-baseline justify-between gap-4">58 <h2 id="h-recent" className="font-display text-2xl font-semibold tracking-tight">{t.recent}</h2>59 {recent.total > recent.items.length && <Link href="/search" className="py-2 text-sm font-semibold text-accent">{t.all} →</Link>}60 </div>61 {recent.items.length > 0 ? <SheetGrid sheets={recent.items} locale={locale} /> : <p className="card px-5 py-12 text-center text-muted">{t.empty}</p>}62 </section>6364 {usedTopics.length > 0 && (65 <section aria-labelledby="h-topics" className="pb-12">66 <h2 id="h-topics" className="mb-4 font-display text-2xl font-semibold tracking-tight">{t.topics}</h2>67 <ul className="grid gap-3 sm:grid-cols-2 lg:grid-cols-4">68 {usedTopics.map((tp) => (69 <li key={tp.slug}>70 <Link href={`/topics/${tp.slug}`} className="card flex min-h-16 items-center justify-between gap-3 px-4 py-3 hover:shadow-card">71 <span className="font-semibold">{tp.name}</span><span className="text-sm text-faint">{fill(t.count, { n: tp.count })}</span>72 </Link>73 </li>74 ))}75 </ul>76 </section>77 )}7879 <section aria-labelledby="h-about" className="card grid gap-4 p-6 sm:grid-cols-[1fr_auto] sm:items-center sm:p-8">80 <div>81 <h2 id="h-about" className="eyebrow">{t.aboutTitle}</h2>82 <p className="mt-2 max-w-[70ch] leading-relaxed text-muted">{t.about}</p>83 <p className="mt-3 text-sm"><Signature /></p>84 </div>85 <Link href="/about" className="btn">{t.aboutLink}</Link>86 </section>87 </div>88 );89}90