import type { Metadata } from "next"; import Link from "next/link"; import { apiSafe } from "@/lib/api"; import { PartyBadge } from "@/components/party"; import { Badge, Card, Empty, Pill } from "@/components/ui"; import { dateTimeFr } from "@/lib/format"; import { PARTY_IDS, partyLabel } from "@/lib/parties"; export const metadata: Metadata = { title: "Bibliothèque documentaire — documents officiels des partis", description: "Plateformes, programmes, cadres financiers et communiqués officiels, versionnés (SHA-256) et analysés par QC26." }; export const revalidate = 300; interface Doc { id: number; party: string; title: string; url: string; type: string; date: string | null; discoveredAt: string; lastCheckedAt: string | null; proposals: number; pages: number | null; isPdf: boolean; versions: number; analyzedAt: string | null; status: string } export default async function Page({ searchParams }: { searchParams: Promise<{ party?: string; type?: string }> }) { const sp = await searchParams; const qs = new URLSearchParams(); if (sp.party) qs.set("party", sp.party); if (sp.type) qs.set("doc_type", sp.type); const data = await apiSafe<{ documents: Doc[] }>(`/api/documents?${qs}`); if (!data) return ; const types = ["plateforme", "cadre_financier", "communique", "document", "page"]; return (
Document Library · sources officielles uniquement

Bibliothèque documentaire

Chaque document est téléchargé depuis le site officiel du parti, haché (SHA-256), versionné et analysé. Quand un parti modifie un document, QC26 conserve les deux versions et affiche les changements.

Tous{PARTY_IDS.map((id) => {partyLabel(id)})} ·{types.map((t) => {t.replace("_", " ")})}
{data.documents.map((d) => ())} {data.documents.length === 0 && }
DocumentPartiTypePagesPropositionsVersionsDernière analyse
{d.title}
{d.url.replace(/^https?:\/\//, "")}
{d.type.replace("_", " ")}{d.isPdf && PDF}{d.pages ?? "—"}{d.proposals}{d.versions}{d.analyzedAt ? dateTimeFr(d.analyzedAt) : en file}
Aucun document pour ce filtre.
); }