import fs from "node:fs"; import path from "node:path"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { DUPLICATES_FILENAME, type DuplicateReport, } from "yt-dlp-transcript-common/lib/duplicates"; // Whether this site has a duplicate-shorts report to show. compose-site.ts writes // public/ only when the per-site `duplicates` toggle is on // AND there's at least one in-scope cluster, so its mere presence is the signal: // no file → the Duplicates nav link hides and the page shows its empty state. // Read synchronously — this is a static export, evaluated once per build. export function hasDuplicates(): boolean { try { const file = path.join(getPaths().exportPublicDir, DUPLICATES_FILENAME); const parsed = JSON.parse(fs.readFileSync(file, "utf8")) as DuplicateReport; return Array.isArray(parsed?.clusters) && parsed.clusters.length > 0; } catch { return false; } }