| 1 | /** |
| 2 | * /robots.txt: everything may be crawled, and where the site's maps are. |
| 3 | * Served from the request's own origin, so a self-hosted g1t names itself. |
| 4 | */ |
| 5 | import type { Route } from "./+types/robots-txt"; |
| 6 | |
| 7 | /** g1t.sh's docs keep their own map; a self-hosted g1t has no docs site. */ |
| 8 | const DOCS_SITEMAP = "https://docs.g1t.sh/sitemap-index.xml"; |
| 9 | |
| 10 | export function loader({ request }: Route.LoaderArgs) { |
| 11 | const site = new URL(request.url).origin; |
| 12 | const lines = ["User-agent: *", "Allow: /", "", `Sitemap: ${site}/sitemap.xml`]; |
| 13 | if (site === "https://g1t.sh") lines.push(`Sitemap: ${DOCS_SITEMAP}`); |
| 14 | return new Response(`${lines.join("\n")}\n`, { |
| 15 | headers: { |
| 16 | "content-type": "text/plain; charset=utf-8", |
| 17 | "cache-control": "public, max-age=86400", |
| 18 | }, |
| 19 | }); |
| 20 | } |