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
+28 -10

No files matched your search

+1 -2
View File
@@ -25,10 +25,9 @@ If you intend to contribute to the code, note that you may need to check out sen
## Environment Variables ## Environment Variables
| Name | Source | BlitzKit Default | Memo | | Name | Source | BlitzKit Default | Memo |
| ------------------------------------------------------------- | -------------------------------------------------------------------------------- | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | | ------------------------------------------------------------- | -------------------------------------------------------------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `PUBLIC_WARGAMING_APPLICATION_ID` | [Wargaming Developer's Room](https://developers.wargaming.net/) | | Application ID needed to communicate with Wargaming APIs. | | `PUBLIC_WARGAMING_APPLICATION_ID` | [Wargaming Developer's Room](https://developers.wargaming.net/) | | Application ID needed to communicate with Wargaming APIs. |
| `PUBLIC_PROMOTE_OPENTEST` | | `false` | Optional boolean dictating whether the website advertises [the opentest subdomain of BlitzKit](https://opentest.blitzkit.app/). | | `PUBLIC_PROMOTE_OPENTEST` | | `false` | Optional boolean dictating whether the website advertises [the opentest subdomain of BlitzKit](https://opentest.blitzkit.app/). |
| `ALLOW_ROBOTS` | | `true` | Toggles between `Allow: /` and `Disallow: /` in the website's `/robots.txt`. This is usually `false` for all BlitzKit's subdomains. |
| `WOTB_GLOSSARY`, `WOTB_GLOSSARY_DOMAIN`, `WOTB_GLOSSARY_PATH` | | | | | `WOTB_GLOSSARY`, `WOTB_GLOSSARY_DOMAIN`, `WOTB_GLOSSARY_PATH` | | | |
| `PUBLIC_GOOGLE_TAG_MANAGER_ID` | [Google Tag Manager](https://tagmanager.google.com/) | `G-GL2JVHCGPQ` | Google Tag Manager's unique identifier for analytical purposes. | | `PUBLIC_GOOGLE_TAG_MANAGER_ID` | [Google Tag Manager](https://tagmanager.google.com/) | `G-GL2JVHCGPQ` | Google Tag Manager's unique identifier for analytical purposes. |
| `PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID` | [Google Analytics](https://analytics.google.com/) | `430711767` | Google Analytics' unique property ID for [BlitzKit's apex domain](https://blitzkit.app/) and subdomains. | | `PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID` | [Google Analytics](https://analytics.google.com/) | `430711767` | Google Analytics' unique property ID for [BlitzKit's apex domain](https://blitzkit.app/) and subdomains. |
+3
View File
@@ -1,4 +1,7 @@
{ {
"robots": false,
"canonical": "https://blitzkit.app",
"paths": { "paths": {
"default": null, "default": null,
"api": null "api": null
+3
View File
@@ -1,4 +1,7 @@
{ {
"robots": false,
"canonical": "https://blitzkit.app",
"paths": { "paths": {
"default": null, "default": null,
"api": "api" "api": "api"
+3
View File
@@ -1,4 +1,7 @@
{ {
"robots": false,
"canonical": "https://blitzkit.app",
"paths": { "paths": {
"default": null, "default": null,
"api": null "api": null
+3
View File
@@ -1,4 +1,7 @@
{ {
"robots": false,
"canonical": "https://blitzkit.app",
"paths": { "paths": {
"default": null, "default": null,
"api": null "api": null
+3
View File
@@ -1,4 +1,7 @@
{ {
"robots": true,
"canonical": "https://blitzkit.app",
"paths": { "paths": {
"default": null, "default": null,
"api": null "api": null
@@ -1,6 +1,8 @@
import { assertSecret } from "@blitzkit/core"; import { assertSecret } from "@blitzkit/core";
interface EnvironmentConfig { interface EnvironmentConfig {
robots: boolean;
canonical: string;
paths: Record<string, string | null>; paths: Record<string, string | null>;
nodes: Record<string, string>; nodes: Record<string, string>;
aliases: Record<string, string>; aliases: Record<string, string>;
+10 -8
View File
@@ -1,20 +1,22 @@
import type { APIContext } from 'astro'; import { environmentConfig } from "@blitzkit/core";
import type { APIContext } from "astro";
const ALLOW_ROBOTS = import.meta.env.ALLOW_ROBOTS;
export async function GET({ request }: APIContext) { export async function GET({ request }: APIContext) {
const config = environmentConfig();
const flags: Record<string, string | null> = { const flags: Record<string, string | null> = {
'User-agent': '*', "User-agent": "*",
Allow: ALLOW_ROBOTS ? '/' : null, Allow: config.robots ? "/" : null,
Disallow: ALLOW_ROBOTS ? null : '/', Disallow: config.robots ? null : "/",
space: null, space: null,
Sitemap: `${new URL(request.url).origin}/sitemap-index.xml`, Sitemap: `${new URL(request.url).origin}/sitemap-index.xml`,
}; };
return new Response( return new Response(
Object.entries(flags) Object.entries(flags)
.map(([key, value]) => (value === null ? '' : `${key}: ${value}`)) .map(([key, value]) => (value === null ? "" : `${key}: ${value}`))
.join('\n'), .join("\n"),
); );
} }