mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: better robots.txt
This commit is contained in:
1 parent
21a37ec6cc
commit
c3d8f15a2a
3 files changed
+12
-15
No files matched your search
Vendored
+1
@@ -130,6 +130,7 @@
|
||||
"outdir",
|
||||
"outfile",
|
||||
"ownedtanks",
|
||||
"partytown",
|
||||
"PIXELFORMAT",
|
||||
"playerachievements",
|
||||
"playerinfo",
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
import { assertSecret } from '@blitzkit/core';
|
||||
import type { APIContext } from 'astro';
|
||||
|
||||
export async function GET({}: APIContext) {
|
||||
export async function GET({ request }: APIContext) {
|
||||
const allowRobots = assertSecret(import.meta.env.ALLOW_ROBOTS) === 'true';
|
||||
const site = assertSecret(import.meta.env.SITE);
|
||||
const flags: Record<string, string | null> = {
|
||||
'User-agent': '*',
|
||||
[allowRobots ? 'Allow' : 'Disallow']: '/',
|
||||
|
||||
space: null,
|
||||
Sitemap: `${new URL(request.url).origin}/sitemap-index.xml`,
|
||||
};
|
||||
|
||||
return new Response(
|
||||
`
|
||||
User-agent: *
|
||||
Allow: /
|
||||
|
||||
${
|
||||
allowRobots
|
||||
? `
|
||||
Host: ${site}
|
||||
Sitemap: ${site}/sitemap-index.xml
|
||||
`
|
||||
: ''
|
||||
}
|
||||
`.trim(),
|
||||
Object.entries(flags)
|
||||
.map(([key, value]) => (value === null ? '' : `${key}: ${value}`))
|
||||
.join('\n'),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user