mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +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",
|
"outdir",
|
||||||
"outfile",
|
"outfile",
|
||||||
"ownedtanks",
|
"ownedtanks",
|
||||||
|
"partytown",
|
||||||
"PIXELFORMAT",
|
"PIXELFORMAT",
|
||||||
"playerachievements",
|
"playerachievements",
|
||||||
"playerinfo",
|
"playerinfo",
|
||||||
|
|||||||
@@ -1,23 +1,19 @@
|
|||||||
import { assertSecret } from '@blitzkit/core';
|
import { assertSecret } from '@blitzkit/core';
|
||||||
import type { APIContext } from 'astro';
|
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 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(
|
return new Response(
|
||||||
`
|
Object.entries(flags)
|
||||||
User-agent: *
|
.map(([key, value]) => (value === null ? '' : `${key}: ${value}`))
|
||||||
Allow: /
|
.join('\n'),
|
||||||
|
|
||||||
${
|
|
||||||
allowRobots
|
|
||||||
? `
|
|
||||||
Host: ${site}
|
|
||||||
Sitemap: ${site}/sitemap-index.xml
|
|
||||||
`
|
|
||||||
: ''
|
|
||||||
}
|
|
||||||
`.trim(),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user