// pages/sitemap.tsx
import { NextApiRequest, NextApiResponse } from 'next';
import { sitemapXml } from '../utils/sitemap';

const Sitemap = () => null;

export async function getServerSideProps({ res }: { res: NextApiResponse }) {
  const xml = await sitemapXml();
  res.setHeader('Content-Type', 'text/xml');
  res.write(xml);
  res.end();

  // Return an empty object for getServerSideProps to indicate success
  return { props: {} };
}

export default Sitemap;
