import type { APIRoute } from 'astro';

/* robots.txt (SEO_SPEC §2): allow all, point to the sitemap. */
export const GET: APIRoute = ({ site }) => {
  const origin = site?.href ?? 'https://cesnimda.co.uk/';
  const body = [
    'User-agent: *',
    'Allow: /',
    '',
    `Sitemap: ${new URL('sitemap.xml', origin).href}`,
    '',
  ].join('\n');
  return new Response(body, { headers: { 'Content-Type': 'text/plain; charset=utf-8' } });
};
