import type { Metadata } from "next"; import Link from "next/link"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { formatBytes } from "yt-dlp-transcript-common/lib/format"; import { REPORT_EXPORT_FILENAMES, REPORT_EXPORT_FORMATS, } from "yt-dlp-transcript-common/lib/report/views"; import { ArticleRowActions } from "../components/ArticleRowActions"; import { ArticleVideoControl } from "../components/ArticleVideoControl"; import { ExportArticlesButton, PrepareArticlesMediaButton } from "../components/ArticlesJobButtons"; import { FetchMissingEvidenceButton } from "../components/FetchMissingEvidenceButton"; import { publishRefusal, reportMediaSummary, type ReportMediaSummary } from "../lib/reportList"; import type { ReportExportsRow } from "../lib/reportListServer"; import { latestArticlesJob, readArticleExports, readArticleRows, readArticlesMediaIndex, type ArticleRow, } from "../lib/articlesServer"; export const dynamic = "force-dynamic"; export const metadata: Metadata = { title: "Articles — Sites" }; // THE ARTICLES (release 26): every article directory under // `transcripts/reports/`, published by the project homepage — not by a site — // in `reports/index.json`'s order, then the drafts. Each article's audience // says which homepage build carries it: the public one only "public" // articles, the private (local-only) one every published article. Publish, // unpublish, reorder and the audience are written through the article // registry (lib/report/registry.ts), as `pnpm ops articles-config` writes // them. The evidence media and the exports are a site's Reports tab's, over // the articles, on the same queue. A site's own pages stay on its Reports tab. // // A static segment beside /sites/[siteId]: a site named "articles" is not // reachable here, as one named "new" is not. export default async function ArticlesPage() { const paths = getPaths(); const { rows, indexError } = await readArticleRows(paths); const published = rows.filter((r) => r.position !== null).map((r) => r.id); const [mediaIndex, exportRows, lastJob, lastExportJob] = await Promise.all([ readArticlesMediaIndex(paths), readArticleExports(paths, published), latestArticlesJob(paths, "reports-prepare"), latestArticlesJob(paths, "reports-export"), ]); const publicCount = rows.filter((r) => r.position !== null && r.audience === "public").length; return (
{published.length} published ({publicCount} public), {rows.length - published.length} draft {rows.length - published.length === 1 ? "" : "s"}
{indexError && ({indexError}
)}
No articles yet. Put one at reports/<articleId>/report.json.
Last prepare job:{" "} {lastJob ? ( {lastJob.id} ) : ( "none among recent jobs" )} {lastJob && <> ({lastJob.status})>}
{mediaIndex ? (Not prepared yet.
)}Last export job:{" "} {lastExportJob ? ( {lastExportJob.id} ) : ( "none among recent jobs" )} {lastExportJob && <> ({lastExportJob.status})>}
{exportRows.length === 0 ? (No published article to export.
) : ({row.id}
{row.kind && <> · {row.kind === "factcheck" ? "fact-check" : "sweep"}>}
{dates.length > 0 && <> · {dates.join(", ")}>}
{row.sections} section{row.sections === 1 ? "" : "s"} · {row.claims} claim {row.claims === 1 ? "" : "s"} · {row.citations} citation{row.citations === 1 ? "" : "s"}
)} {row.status !== "missing" &&{p.path}}
{p.path && ": "}
{p.message}
Prepared {new Date(summary.preparedAt).toLocaleString()}: {summary.moments} moment {summary.moments === 1 ? "" : "s"} {summary.momentsByKind.length > 0 && <> ({summary.momentsByKind.map((k) => `${k.count} ${k.kind}`).join(", ")})>} , {formatBytes(summary.totalBytes)}.
{summary.problems.length === 0 ? (No problems.
) : ({p.kind} {p.moment ?? p.report ?? "?"}
{p.citations && p.citations.length > 0 && (
(cited by {p.citations.join(", ")})
)}
: {p.message}
{row.reportId}{" "}
{manifest ? `exported ${new Date(manifest.exportedAt).toLocaleString()}` : "not exported yet"}
Revision {manifest.revision.revision} · {manifest.revision.date.slice(0, 10)} ·{" "}
{manifest.revision.commit.slice(0, 12)}
{REPORT_EXPORT_FILENAMES[f]} {formatBytes(manifest.files[f]!.bytes)}{" "}
{publishable.files[f] ? (
published on build
) : (
local only
)}
{note}
))}