import type { APIRoute } from 'astro';

const site = 'https://workroot.in';

/**
 * Sitemap Index - Provides links to individual sitemaps
 * Use this when you have multiple content types or large amounts of content
 * Currently serves as documentation for future scalability
 */
export const GET: APIRoute = async () => {
  const lastmod = new Date().toISOString();

  const sitemapIndex = `<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>${site}/sitemap.xml</loc>
    <lastmod>${lastmod}</lastmod>
  </sitemap>
</sitemapindex>`;

  return new Response(sitemapIndex, {
    headers: {
      'Content-Type': 'application/xml; charset=utf-8',
      'Cache-Control': 'public, max-age=3600',
      'X-Robots-Tag': 'noindex',
    },
  });
};
