Repository Public
1import Link from "next/link";2import type { Locale } from "@/schema";3import type { PublicCard } from "@/server/sheets";4import { dict, fill, formatDate, LEVEL_LABEL } from "@/i18n/dict";5import { Cover } from "@/components/cover";6import { Inline } from "@/renderer/inline";7import { plainMath } from "@/renderer/mathtext";89const T = dict({ min: ["{n} min de lecture", "{n} min read"], featured: ["En vedette", "Featured"], empty: ["Aucune fiche ne correspond pour l’instant.", "No sheet matches yet."] });1011export function SheetCard({ sheet, locale, large }: { sheet: PublicCard; locale: Locale; large?: boolean }) {12 const t = T(locale);13 const level = LEVEL_LABEL(locale)[sheet.level as "beginner"] ?? sheet.level;14 return (15 <article className={`card group relative flex flex-col overflow-hidden transition-shadow hover:shadow-card ${large ? "sm:flex-row" : ""}`}>16 <Cover seed={sheet.slug} theme={sheet.theme} accent={sheet.accent} formula={sheet.formula} className={large ? "h-40 sm:h-auto sm:w-[44%] sm:min-h-56" : "h-36"} />17 <div className="flex flex-1 flex-col gap-2 p-5">18 <div className="eyebrow flex flex-wrap items-center gap-x-2 gap-y-1">19 {sheet.featured && <span className="text-signal">{t.featured}</span>}20 {sheet.topics.slice(0, 2).map((tp) => <span key={tp.slug}>{tp.name}</span>)}21 {sheet.locale !== locale && <span className="rounded border border-line px-1.5 py-px">{sheet.locale.toUpperCase()}</span>}22 </div>23 <h3 className={`font-display font-semibold leading-snug tracking-tight ${large ? "text-2xl sm:text-[1.75rem]" : "text-xl"}`} lang={sheet.locale}>24 <Link href={`/s/${sheet.slug}`} className="after:absolute after:inset-0 after:content-[''] rounded">{plainMath(sheet.title)}</Link>25 </h3>26 {sheet.summary && <p className="line-clamp-3 text-[0.9375rem] leading-relaxed text-muted" lang={sheet.locale}><Inline text={sheet.summary} /></p>}27 <p className="mt-auto pt-2 text-sm text-faint">{level} · {fill(t.min, { n: sheet.readingMinutes })} · <time dateTime={sheet.publishedAt}>{formatDate(sheet.publishedAt, locale)}</time></p>28 </div>29 </article>30 );31}3233export function SheetGrid({ sheets, locale }: { sheets: PublicCard[]; locale: Locale }) {34 if (sheets.length === 0) return <p className="card px-5 py-10 text-center text-muted">{T(locale).empty}</p>;35 return <div className="grid gap-5 sm:grid-cols-2 lg:grid-cols-3">{sheets.map((s) => <SheetCard key={`${s.locale}:${s.slug}`} sheet={s} locale={locale} />)}</div>;36}37