mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-17 10:53:57 +01:00
21 lines
535 B
TypeScript
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'),
|
|
);
|
|
}
|