From 8cdaa9e69a965cd9f3ed4ea9fb1c7827cb609f32 Mon Sep 17 00:00:00 2001 From: SkyfallWasTaken Date: Sun, 14 Jul 2024 13:40:05 +0100 Subject: [PATCH] Add sitemap.xml, robots.txt --- astro.config.mjs | 1 + bun.lockb | Bin 444071 -> 444071 bytes src/components/BaseHead.astro | 5 ++++- src/pages/robots.txt.ts | 16 ++++++++++++++++ svelte.config.js | 6 +++--- tsconfig.json | 1 + 6 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/pages/robots.txt.ts diff --git a/astro.config.mjs b/astro.config.mjs index 28b48af..f19624c 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -7,6 +7,7 @@ import svelte from "@astrojs/svelte"; // https://astro.build/config export default defineConfig({ + // FIXME: don't hardcode this site: "https://skyfall.dev", integrations: [mdx(), sitemap(), tailwind(), svelte()], /* output: "hybrid", // or 'server' diff --git a/bun.lockb b/bun.lockb index a71aa78d2d3182c7b3ebbe41c9cef2c5c2f7377e..5ee80d894d6ebce898f155d42aa1f3ef6cd3d86e 100755 GIT binary patch delta 39 tcmZ49E4{o|x}k-!g{g&k3yW_PJ7b)Qo`Ifudq@)t5VLL%X<`d@0RRQ641xdv delta 39 pcmZ49E4{o|x}k-!g{g&k3yW_PI}-yKw1+gY05R+KkS4ZZ7Xa<|3oZZv diff --git a/src/components/BaseHead.astro b/src/components/BaseHead.astro index 74a428f..80c743a 100644 --- a/src/components/BaseHead.astro +++ b/src/components/BaseHead.astro @@ -51,5 +51,8 @@ const { title, description, image = "/blog-placeholder-1.jpg" } = Astro.props; + + + - \ No newline at end of file + diff --git a/src/pages/robots.txt.ts b/src/pages/robots.txt.ts new file mode 100644 index 0000000..bfb5261 --- /dev/null +++ b/src/pages/robots.txt.ts @@ -0,0 +1,16 @@ +import type { APIRoute } from "astro"; + +const robotsTxt = ` +User-agent: * +Allow: / + +Sitemap: ${new URL("sitemap-index.xml", import.meta.env.SITE).href} +`.trim(); + +export const GET: APIRoute = () => { + return new Response(robotsTxt, { + headers: { + "Content-Type": "text/plain; charset=utf-8", + }, + }); +}; diff --git a/svelte.config.js b/svelte.config.js index 522c1ef..cf44f38 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,5 +1,5 @@ -import { vitePreprocess } from '@astrojs/svelte'; +import { vitePreprocess } from "@astrojs/svelte"; export default { - preprocess: vitePreprocess(), -} + preprocess: vitePreprocess(), +}; diff --git a/tsconfig.json b/tsconfig.json index 0fc51d7..a9e03bd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,6 @@ { "extends": "astro/tsconfigs/strict", + "exclude": ["dist/**"], "compilerOptions": { "strictNullChecks": true }