const BASE_URL = "https://llmhosts.com";

const PAGES = [
  {
    title: "LLMHosts — Your GPU, Real AI Infrastructure, From Anywhere",
    url: `${BASE_URL}/`,
    description:
      "Turn your home GPU into production AI infrastructure. OpenAI + Anthropic compatible proxy with intelligent routing, verified cache, and remote access.",
    date: "2026-02-22T00:00:00Z",
  },
  {
    title: "LLMHosts Pricing — Free, Pro, and Team Plans",
    url: `${BASE_URL}/pricing`,
    description:
      "Compare LLMHosts plans. Free tier for personal use, Pro at $29/mo, Team at $99/mo.",
    date: "2026-02-22T00:00:00Z",
  },
  {
    title: "LLMHosts Documentation",
    url: `${BASE_URL}/docs`,
    description: "Installation, CLI commands, API reference, and deployment guides.",
    date: "2026-02-22T00:00:00Z",
  },
];

export async function GET() {
  const now = new Date().toUTCString();

  const items = PAGES.map(
    (page) => `    <item>
      <title><![CDATA[${page.title}]]></title>
      <link>${page.url}</link>
      <guid isPermaLink="true">${page.url}</guid>
      <description><![CDATA[${page.description}]]></description>
      <pubDate>${new Date(page.date).toUTCString()}</pubDate>
    </item>`,
  ).join("\n");

  const xml = `<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>LLMHosts</title>
    <link>${BASE_URL}</link>
    <description>Turn your home GPU into production AI infrastructure accessible from anywhere.</description>
    <language>en-us</language>
    <lastBuildDate>${now}</lastBuildDate>
    <atom:link href="${BASE_URL}/feeds/articles.xml" rel="self" type="application/rss+xml"/>
${items}
  </channel>
</rss>`;

  return new Response(xml, {
    headers: {
      "Content-Type": "application/rss+xml; charset=utf-8",
      "Cache-Control": "public, max-age=3600, s-maxage=3600",
    },
  });
}
