import { promises as fs } from "node:fs";
import path from "node:path";

type FeaturedVideosFile = {
  videoIds: string[];
};

export async function readFeaturedVideoIds(): Promise<string[]> {
  const p = path.join(process.cwd(), "content", "featured-videos.json");
  try {
    const raw = await fs.readFile(p, "utf8");
    const parsed = JSON.parse(raw) as FeaturedVideosFile;
    return Array.isArray(parsed.videoIds)
      ? parsed.videoIds.filter((x) => typeof x === "string")
      : [];
  } catch {
    return [];
  }
}
