diff --git a/astro.config.mjs b/astro.config.mjs index ed321dd..44eb332 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -4,11 +4,13 @@ import tailwind from "@astrojs/tailwind"; import mdx from "@astrojs/mdx"; import rehypePrettyCode from "rehype-pretty-code"; import rehypeSlug from "rehype-slug"; +import sitemap from "@astrojs/sitemap"; // https://astro.build/config export default defineConfig({ site: "https://www.juancman.dev/", integrations: [ + sitemap(), react(), tailwind({ applyBaseStyles: false, diff --git a/package.json b/package.json index 520f35b..a7fbb76 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@astrojs/mdx": "^3.1.2", "@astrojs/react": "^3.6.0", "@astrojs/rss": "^4.0.7", + "@astrojs/sitemap": "^3.1.6", "@astrojs/tailwind": "^5.1.0", "@astrojs/vercel": "^7.7.2", "@radix-ui/react-dialog": "^1.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 81f08d4..d8b7496 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ importers: '@astrojs/rss': specifier: ^4.0.7 version: 4.0.7 + '@astrojs/sitemap': + specifier: ^3.1.6 + version: 3.1.6 '@astrojs/tailwind': specifier: ^5.1.0 version: 5.1.0(astro@4.11.3(typescript@5.5.2))(tailwindcss@3.4.4) @@ -168,6 +171,9 @@ packages: '@astrojs/rss@4.0.7': resolution: {integrity: sha512-ZEG55XFB19l+DplUvBISmz04UbjDtKliRO4Y5+ERRhAMjgCVVobEBNE6ZwWG1h6orWUocy4nfPihKXDyB73x9g==} + '@astrojs/sitemap@3.1.6': + resolution: {integrity: sha512-1Qp2NvAzVImqA6y+LubKi1DVhve/hXXgFvB0szxiipzh7BvtuKe4oJJ9dXSqaubaTkt4nMa6dv6RCCAYeB6xaQ==} + '@astrojs/tailwind@5.1.0': resolution: {integrity: sha512-BJoCDKuWhU9FT2qYg+fr6Nfb3qP4ShtyjXGHKA/4mHN94z7BGcmauQK23iy+YH5qWvTnhqkd6mQPQ1yTZTe9Ig==} peerDependencies: @@ -959,6 +965,9 @@ packages: '@types/nlcst@2.0.3': resolution: {integrity: sha512-vSYNSDe6Ix3q+6Z7ri9lyWqgGhJTmzRjZRqyq15N0Z/1/UnVsno9G/N40NBijoYx2seFDIl0+B2mgAb9mezUCA==} + '@types/node@17.0.45': + resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==} + '@types/prop-types@15.7.12': resolution: {integrity: sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==} @@ -971,6 +980,9 @@ packages: '@types/sanitize-html@2.11.0': resolution: {integrity: sha512-7oxPGNQHXLHE48r/r/qjn7q0hlrs3kL7oZnGj0Wf/h9tj/6ibFyRkNbsDxaBBZ4XUZ0Dx5LGCyDJ04ytSofacQ==} + '@types/sax@1.2.7': + resolution: {integrity: sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A==} + '@types/unist@2.0.10': resolution: {integrity: sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA==} @@ -2509,6 +2521,9 @@ packages: sanitize-html@2.13.0: resolution: {integrity: sha512-Xff91Z+4Mz5QiNSLdLWwjgBDm5b1RU6xBT0+12rapjiaR7SwfRdjw8f+6Rir2MXKLrDicRFHdb51hGOAxmsUIA==} + sax@1.4.1: + resolution: {integrity: sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==} + scheduler@0.23.2: resolution: {integrity: sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==} @@ -2562,6 +2577,11 @@ packages: sisteransi@1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} + sitemap@7.1.2: + resolution: {integrity: sha512-ARCqzHJ0p4gWt+j7NlU5eDlIO9+Rkr/JhPFZKKQ1l5GCus7rJH4UdrlVAh0xC/gDS/Qir2UMxqYNHtsKr2rpCw==} + engines: {node: '>=12.0.0', npm: '>=5.6.0'} + hasBin: true + source-map-js@1.2.0: resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} engines: {node: '>=0.10.0'} @@ -2580,6 +2600,9 @@ packages: resolution: {integrity: sha512-UhDfHmA92YAlNnCfhmq0VeNL5bDbiZGg7sZ2IvPsXubGkiNa9EC+tUTsjBRsYUAz87btI6/1wf4XoVvQ3uRnmQ==} engines: {node: '>=18'} + stream-replace-string@2.0.0: + resolution: {integrity: sha512-TlnjJ1C0QrmxRNrON00JvaFFlNh5TTG00APw23j74ET7gkQpTASi6/L2fuiav8pzK715HXtUeClpBTw2NPSn6w==} + string-width@4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} @@ -3108,6 +3131,12 @@ snapshots: fast-xml-parser: 4.4.0 kleur: 4.1.5 + '@astrojs/sitemap@3.1.6': + dependencies: + sitemap: 7.1.2 + stream-replace-string: 2.0.0 + zod: 3.23.8 + '@astrojs/tailwind@5.1.0(astro@4.11.3(typescript@5.5.2))(tailwindcss@3.4.4)': dependencies: astro: 4.11.3(typescript@5.5.2) @@ -3864,6 +3893,8 @@ snapshots: dependencies: '@types/unist': 3.0.2 + '@types/node@17.0.45': {} + '@types/prop-types@15.7.12': {} '@types/react-dom@18.3.0': @@ -3879,6 +3910,10 @@ snapshots: dependencies: htmlparser2: 8.0.2 + '@types/sax@1.2.7': + dependencies: + '@types/node': 17.0.45 + '@types/unist@2.0.10': {} '@types/unist@3.0.2': {} @@ -5889,6 +5924,8 @@ snapshots: parse-srcset: 1.0.2 postcss: 8.4.38 + sax@1.4.1: {} + scheduler@0.23.2: dependencies: loose-envify: 1.4.0 @@ -5954,6 +5991,13 @@ snapshots: sisteransi@1.0.5: {} + sitemap@7.1.2: + dependencies: + '@types/node': 17.0.45 + '@types/sax': 1.2.7 + arg: 5.0.2 + sax: 1.4.1 + source-map-js@1.2.0: {} source-map@0.7.4: {} @@ -5964,6 +6008,8 @@ snapshots: stdin-discarder@0.2.2: {} + stream-replace-string@2.0.0: {} + string-width@4.2.3: dependencies: emoji-regex: 8.0.0 diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 2e467ec..f382868 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -25,6 +25,7 @@ const { title, description, lang } = Astro.props; type="application/rss+xml" href={new URL("rss.xml", Astro.site)} /> + {title} 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", + }, + }); +};