robots.txt.ts (571B)
1 import type { APIRoute } from 'astro'; 2 3 /** 4 * robots.txt, generated from `site` in astro.config.mjs so the Sitemap line 5 * always matches the deployed origin — nothing to keep in sync by hand. The 6 * catalog is public reference material, so everything is crawlable. 7 */ 8 export const GET: APIRoute = ({ site }) => { 9 const sitemap = site ? new URL('sitemap-index.xml', site).href : '/sitemap-index.xml'; 10 const body = `User-agent: * 11 Allow: / 12 13 Sitemap: ${sitemap} 14 `; 15 return new Response(body, { 16 headers: { 'Content-Type': 'text/plain; charset=utf-8' }, 17 }); 18 };