import { cache } from "react"; import { readChannelConfig } from "yt-dlp-transcript-common/controller/channels"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; // The layout and the page both need the channel's config — the layout for the // title and whether to offer the Videos tab, the page for everything else. React // `cache()` dedupes them into ONE read per request. Without it, every channel // route pays two reads of the same file for the same render. // // Request-scoped, not a process cache: the memo lives for the duration of one // render pass, so a config edited by the form on the previous request is read // fresh on the next one. export const readChannelConfigCached = cache(async (slug: string) => readChannelConfig(getPaths(), slug), );