2024-10-14 10:47:49 -05:00
|
|
|
import type { APIContext } from 'astro';
|
|
|
|
|
|
2025-08-04 20:11:51 -05:00
|
|
|
const ALLOW_ROBOTS = import.meta.env.ALLOW_ROBOTS === 'true';
|
|
|
|
|
|
2025-04-03 12:23:53 -05:00
|
|
|
export async function GET({ request }: APIContext) {
|
|
|
|
|
const flags: Record<string, string | null> = {
|
|
|
|
|
'User-agent': '*',
|
2025-08-04 20:11:51 -05:00
|
|
|
Allow: ALLOW_ROBOTS ? '/' : null,
|
|
|
|
|
Disallow: ALLOW_ROBOTS ? null : '/',
|
2025-04-03 12:23:53 -05:00
|
|
|
|
|
|
|
|
space: null,
|
|
|
|
|
Sitemap: `${new URL(request.url).origin}/sitemap-index.xml`,
|
|
|
|
|
};
|
2024-10-14 10:47:49 -05:00
|
|
|
|
2024-11-17 12:29:57 -06:00
|
|
|
return new Response(
|
2025-04-03 12:23:53 -05:00
|
|
|
Object.entries(flags)
|
|
|
|
|
.map(([key, value]) => (value === null ? '' : `${key}: ${value}`))
|
|
|
|
|
.join('\n'),
|
2024-11-17 12:29:57 -06:00
|
|
|
);
|
2024-10-14 10:47:49 -05:00
|
|
|
}
|