simplify robots.txt

This commit is contained in:
tresabhi committed 2026-08-12 11:46:45 -05:00
1 parent 52630596b8
commit 3152c18840
8 files changed
+42 -24

No files matched your search

@@ -1,6 +1,8 @@
import { assertSecret } from "@blitzkit/core";
interface EnvironmentConfig {
robots: boolean;
canonical: string;
paths: Record<string, string | null>;
nodes: Record<string, string>;
aliases: Record<string, string>;
+10 -8
View File
@@ -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"),
);
}