import Link from "next/link"; import { FileText } from "lucide-react"; import { fmtDate, fmtInt, href, t, type Locale } from "@/lib/i18n"; import type { PaperSummary } from "@/lib/papers/types"; export function AuthorsLine({ authors, locale, link = true }: { authors: PaperSummary["authors"]; locale: Locale; link?: boolean }) { return {authors.map((a, i) => {i > 0 && (i === authors.length - 1 ? (locale === "fr" ? " et " : " and ") : ", ")}{link ? {a.display_name} : a.display_name})}; } export function StatusChips({ p, locale }: { p: PaperSummary; locale: Locale }) { const d = t(locale); return ( {p.status !== "published" && {d.misc.status[p.status as keyof typeof d.misc.status]}} {p.publication_status !== "working_paper" && {d.misc.pubStatus[p.publication_status as keyof typeof d.misc.pubStatus]}} {p.notice && {p.notice}} {p.has_pdf ? {d.papers.pdf}{p.pages ? ` · ${p.pages} ${d.papers.pages}` : ""} : {d.paper.notAvailable}} ); } function excerpt(p: PaperSummary, n = 320) { const s = (p.abstract?.[0] ?? "").replace(/\s+/g, " "); return s.length > n ? s.slice(0, n).replace(/\s\S*$/, "") + "…" : s; } const seriesName = (p: PaperSummary, locale: Locale) => locale === "fr" ? p.series_name_fr : p.series_name_en; export function PaperCard({ p, locale, badge }: { p: PaperSummary; locale: Locale; badge?: string }) { const d = t(locale); return (
{p.identifier} {badge && {badge}}{p.year ?? ""}

{locale === "fr" && p.title_fr ? p.title_fr : p.title}

{excerpt(p, 260)}

{p.domain && {locale === "fr" ? p.domain.name_fr : p.domain.name_en}} {d.papers.view} →
); } export function PaperRow({ p, locale, compact = false }: { p: PaperSummary; locale: Locale; compact?: boolean }) { const d = t(locale); return (
{p.identifier}

{locale === "fr" && p.title_fr ? p.title_fr : p.title}

{!compact && p.subtitle &&

{p.subtitle}

}

· {seriesName(p, locale)} · {fmtDate(locale, p.first_released_on, p.first_released_precision)}{p.last_revised_on && p.last_revised_on !== p.first_released_on ? ` · ${d.paper.revised.toLowerCase()} ${fmtDate(locale, p.last_revised_on, p.last_revised_precision)}` : ""}{p.version_label ? ` · ${p.version_label}` : ""}

{!compact &&

{excerpt(p)}

}
{p.domain && {locale === "fr" ? p.domain.name_fr : p.domain.name_en}} {!compact && p.keywords.slice(0, 4).map((k) => {k})}
); } export function PaperTable({ items, locale }: { items: PaperSummary[]; locale: Locale }) { const d = t(locale); return (
{items.map((p) => )}
{d.papers.number}{d.paper.identifier}{d.paper.authors}{d.paper.year}{d.paper.version}{d.paper.domain}{d.paper.pagesLabel}{d.paper.viewsLabel}{d.paper.downloadsLabel}
{p.identifier}{p.title}{p.year ?? ""}{p.version_label ?? ""}{p.domain ? (locale === "fr" ? p.domain.name_fr : p.domain.name_en) : ""}{p.pages ?? ""}{fmtInt(locale, p.view_count)}{fmtInt(locale, p.download_count)}
); }