import type { NextApiRequest, NextApiResponse } from 'next';

const base = 'https://gsa-sust.org';
const pages = ['/', '/about-gsa', '/about-gaibandha', '/contact', '/members', '/signin', '/signup', '/events', '/gallery', '/previous-committees', '/terms-and-conditions'];

export default function handler(req: NextApiRequest, res: NextApiResponse) {
  const now = new Date().toISOString();
  const urls = pages.map(p => `
    <url>
      <loc>${base}${p}</loc>
      <lastmod>${now}</lastmod>
      <changefreq>monthly</changefreq>
      <priority>${p === '/' ? '1.0' : '0.8'}</priority>
    </url>`).join('');
  const xml = `<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">${urls}</urlset>`;
  res.setHeader('Content-Type', 'application/xml');
  res.status(200).send(xml.trim());
}
