import { notFound } from "next/navigation"; import { reportCitationNumbers } from "yt-dlp-transcript-common/lib/report/uses"; import AppShell, { type Crumb } from "@/components/shell/AppShell"; import EvidenceWalk, { type WalkItem } from "@/components/articles/EvidenceWalk"; import { articleHref } from "@/lib/articles/href"; import { readArticleNotes, readReportFile } from "@/lib/articles/sites"; import { corpusNotesFile } from "@/lib/paths"; import { linkedProjects } from "@/lib/articles/links.mjs"; import { sourceFor } from "@/lib/articles/sources.mjs"; import type { NotesRead } from "@/lib/annotations/types"; // Every citation of one article, one per screen, in the article's own // numbering, wherever the article lives (`site` is a site's id or // ARTICLES_KEY). `c` opens on that citation. export default async function EvidencePage({ site, reportId, c, crumbs, }: { site: string; reportId: string; c?: string; // The header's crumbs before the article's own. crumbs: Crumb[]; }) { const read = await readReportFile(site, reportId); if (!read.report) notFound(); const r = read.report; const numbers = reportCitationNumbers(r); const items: WalkItem[] = [...numbers.entries()] .sort((a, b) => a[1] - b[1]) .map(([id, number]) => ({ id, number, kind: r.citations?.[id]?.kind ?? "?", quote: r.citations?.[id]?.quote ?? "" })); const at = Math.max(0, items.findIndex((i) => i.id === c)); const [notes, source] = await Promise.all([readArticleNotes(site, reportId), sourceFor(site, reportId)]); const links = await linkedProjects(site, reportId, { workspace: source?.workspace ?? null }); const initialNotes: NotesRead = { subject: { kind: "article", site, report: reportId }, file: corpusNotesFile(site, reportId) ?? "", token: notes.token, doc: notes.doc, source: notes.doc?.source ?? null, }; return (
({ id: p.id, title: p.title, generatedBy: p.generatedBy }))} />
); }