Files
blitzkit/packages/website/src/pages/robots.txt.ts
T

23 lines
419 B
TypeScript
Raw Normal View History

2024-10-14 10:47:49 -05:00
import { assertSecret } from '@blitzkit/core';
import type { APIContext } from 'astro';
export async function GET({}: APIContext) {
const allowRobots = assertSecret(import.meta.env.ALLOW_ROBOTS) === 'true';
2024-10-14 10:52:40 -05:00
const site = assertSecret(import.meta.env.SITE);
2024-10-14 10:47:49 -05:00
2024-11-17 12:29:57 -06:00
return new Response(
`
User-agent: *
2024-11-17 12:44:42 -06:00
Allow: /
2024-10-14 10:47:49 -05:00
2024-11-17 12:29:57 -06:00
${
allowRobots
? `
Host: ${site}
Sitemap: ${site}/sitemap-index.xml
`
: ''
}
`.trim(),
);
2024-10-14 10:47:49 -05:00
}