Files
blitzkit/packages/website/src/pages/robots.txt.ts
T
2025-08-12 09:15:20 -05:00

21 lines
535 B
TypeScript

import type { APIContext } from 'astro';
const ALLOW_ROBOTS = import.meta.env.ALLOW_ROBOTS;
export async function GET({ request }: APIContext) {
const flags: Record<string, string | null> = {
'User-agent': '*',
Allow: ALLOW_ROBOTS ? '/' : null,
Disallow: ALLOW_ROBOTS ? null : '/',
space: null,
Sitemap: `${new URL(request.url).origin}/sitemap-index.xml`,
};
return new Response(
Object.entries(flags)
.map(([key, value]) => (value === null ? '' : `${key}: ${value}`))
.join('\n'),
);
}