diff --git a/astro.config.mjs b/astro.config.mjs index 5d227ff..3310ed3 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -10,6 +10,7 @@ import remarkMath from "remark-math" import { remarkReadingTime } from "./src/plugins/remark-reading-time.mjs" import svelte from "@astrojs/svelte" import swup from '@swup/astro'; +import sitemap from '@astrojs/sitemap'; const oklchToHex = (str) => { const DEFAULT_HUE = 250 @@ -49,6 +50,7 @@ export default defineConfig({ Image: false, }), svelte(), + sitemap(), ], markdown: { remarkPlugins: [remarkMath, remarkReadingTime], diff --git a/package.json b/package.json index f8694e3..1df4de0 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ }, "dependencies": { "@astrojs/check": "^0.5.9", + "@astrojs/sitemap": "^3.1.2", "@astrojs/rss": "^4.0.5", "@astrojs/svelte": "^5.2.0", "@astrojs/tailwind": "^5.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 077cfc2..ea08224 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ dependencies: '@astrojs/check': specifier: ^0.5.9 version: 0.5.9(typescript@5.4.2) + '@astrojs/sitemap': + specifier: ^3.1.2 + version: 3.1.2 '@astrojs/rss': specifier: ^4.0.5 version: 4.0.5 @@ -228,6 +231,12 @@ packages: prismjs: 1.29.0 dev: false + /@astrojs/sitemap@3.1.2: + resolution: {integrity: sha512-FxOJldIl5ltZ5CNjocQxHkAO9orwHBjqtaU28o4smobp9vowS0nbGp+I9CrPxkzWdl1crSDm9vjL9tnvG1DSug==} + dependencies: + sitemap: 7.1.1 + zod: 3.22.4 + /@astrojs/rss@4.0.5: resolution: {integrity: sha512-IyJVL6z09AQtxbgLaAwebT3T5YKe4oTHDesqydJv1KLHw+zEzzMCFuuNsEyxjiqu7df9+DDCpDXLj/WRiEUXvw==} dependencies: @@ -2876,6 +2885,10 @@ packages: '@types/unist': 2.0.10 dev: false + /@types/node@17.0.45: + resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==} + dev: false + /@types/node@20.11.28: resolution: {integrity: sha512-M/GPWVS2wLkSkNHVeLkrF2fD5Lx5UC4PxA0uZcKc6QqbIQUJyW1jVjueJYi1z8n0I5PxYrtpnPnWglE+y9A0KA==} dependencies: @@ -2892,6 +2905,12 @@ packages: '@types/node': 20.11.28 dev: false + /@types/sax@1.2.7: + resolution: {integrity: sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A==} + dependencies: + '@types/node': 20.11.28 + dev: false + /@types/sanitize-html@2.11.0: resolution: {integrity: sha512-7oxPGNQHXLHE48r/r/qjn7q0hlrs3kL7oZnGj0Wf/h9tj/6ibFyRkNbsDxaBBZ4XUZ0Dx5LGCyDJ04ytSofacQ==} dependencies: @@ -7840,6 +7859,17 @@ packages: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} dev: false + /sitemap@7.1.1: + resolution: {integrity: sha512-mK3aFtjz4VdJN0igpIJrinf3EO8U8mxOPsTBzSsy06UtjZQJ3YY3o3Xa7zSc5nMqcMrRwlChHZ18Kxg0caiPBg==} + engines: {node: '>=12.0.0', npm: '>=5.6.0'} + hasBin: true + dependencies: + '@types/node': 17.0.45 + '@types/sax': 1.2.7 + arg: 5.0.2 + sax: 1.3.0 + dev: false + /slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} diff --git a/src/pages/robots.txt.ts b/src/pages/robots.txt.ts new file mode 100644 index 0000000..9649a44 --- /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', + }, + }); +}; \ No newline at end of file