import type { NewsSource } from "./types";

/**
 * Curated allowlist of orthopaedic news sources.
 *
 * We intentionally hardcode this list rather than making it editable via
 * CMS — the news page is a live aggregator and we need verifiable, vetted
 * publishers. If a feed URL breaks at runtime, `fetchAllNews()` in
 * `cache.ts` will log and skip it gracefully so the rest of the page
 * still renders.
 *
 * When adding a new source:
 *   1. Verify the feed URL returns valid RSS 2.0 or Atom XML (not HTML).
 *   2. Pick an id that is url-safe and stable (it appears in filters).
 *   3. Point `homepageUrl` at the publisher's top-level site.
 */
export const NEWS_SOURCES: readonly NewsSource[] = [
  {
    id: "orthopedics-this-week",
    name: "Orthopedics This Week",
    feedUrl: "https://ryortho.com/feed/",
    homepageUrl: "https://ryortho.com/",
  },
  {
    id: "bonezone",
    name: "BoneZone",
    feedUrl: "https://bonezonepub.com/feed/",
    homepageUrl: "https://bonezonepub.com/",
  },
] as const;

export function getSourceById(id: string): NewsSource | undefined {
  return NEWS_SOURCES.find((s) => s.id === id);
}
