mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
simplify robots.txt
This commit is contained in:
1 parent
52630596b8
commit
3152c18840
8 files changed
+42
-24
No files matched your search
@@ -1,20 +1,22 @@
|
||||
import type { APIContext } from 'astro';
|
||||
|
||||
const ALLOW_ROBOTS = import.meta.env.ALLOW_ROBOTS;
|
||||
import { environmentConfig } from "@blitzkit/core";
|
||||
import type { APIContext } from "astro";
|
||||
|
||||
export async function GET({ request }: APIContext) {
|
||||
const config = environmentConfig();
|
||||
|
||||
const flags: Record<string, string | null> = {
|
||||
'User-agent': '*',
|
||||
Allow: ALLOW_ROBOTS ? '/' : null,
|
||||
Disallow: ALLOW_ROBOTS ? null : '/',
|
||||
"User-agent": "*",
|
||||
Allow: config.robots ? "/" : null,
|
||||
Disallow: config.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'),
|
||||
.map(([key, value]) => (value === null ? "" : `${key}: ${value}`))
|
||||
.join("\n"),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user