From f21da6c25236c095c5a3ae28dff12236d04ea84e Mon Sep 17 00:00:00 2001 From: Talgat The Random <36820511+RND332@users.noreply.github.com> Date: Sat, 15 Jun 2024 01:33:26 +0300 Subject: [PATCH] chore: Update astro.config.mjs with sitemap integration --- astro.config.mjs | 6 ++++-- package.json | 1 + pnpm-lock.yaml | 46 ++++++++++++++++++++++++++++++++++++++++ src/layouts/Layout.astro | 1 + src/pages/robots.txt.ts | 16 ++++++++++++++ 5 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 src/pages/robots.txt.ts diff --git a/astro.config.mjs b/astro.config.mjs index 5adeb1f..8ae1002 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -2,12 +2,14 @@ import { defineConfig, passthroughImageService } from 'astro/config'; import tailwind from "@astrojs/tailwind"; import mdx from '@astrojs/mdx'; +import sitemap from "@astrojs/sitemap"; + // https://astro.build/config export default defineConfig({ - integrations: [tailwind(), mdx()], + integrations: [tailwind(), mdx(), sitemap()], site: 'https://rnd332.com', build: { - inlineStylesheets: 'always', + inlineStylesheets: 'always' }, image: { service: passthroughImageService() diff --git a/package.json b/package.json index 56e8631..f774e17 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@astrojs/check": "^0.7.0", "@astrojs/mdx": "^3.1.0", "@astrojs/react": "^3.4.0", + "@astrojs/sitemap": "^3.1.5", "@astrojs/tailwind": "^5.1.0", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f885869..3719f9e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,6 +17,9 @@ importers: '@astrojs/react': specifier: ^3.4.0 version: 3.4.0(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(vite@5.2.12) + '@astrojs/sitemap': + specifier: ^3.1.5 + version: 3.1.5 '@astrojs/tailwind': specifier: ^5.1.0 version: 5.1.0(astro@4.9.3(typescript@5.4.5))(tailwindcss@3.4.4) @@ -108,6 +111,9 @@ packages: react: ^17.0.2 || ^18.0.0 || ^19.0.0-beta react-dom: ^17.0.2 || ^18.0.0 || ^19.0.0-beta + '@astrojs/sitemap@3.1.5': + resolution: {integrity: sha512-GLdzJ01387Uzb8RKYpsYLlg/GzoPnGbmDeQNkarSE11i2+l9Qp8Nj/WoTEy9nkTS25fxxy0kxDfJmreeVleCqg==} + '@astrojs/tailwind@5.1.0': resolution: {integrity: sha512-BJoCDKuWhU9FT2qYg+fr6Nfb3qP4ShtyjXGHKA/4mHN94z7BGcmauQK23iy+YH5qWvTnhqkd6mQPQ1yTZTe9Ig==} peerDependencies: @@ -822,6 +828,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==} @@ -831,6 +840,9 @@ packages: '@types/react@18.3.3': resolution: {integrity: sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==} + '@types/sax@1.2.7': + resolution: {integrity: sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A==} + '@types/unist@2.0.10': resolution: {integrity: sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA==} @@ -2071,6 +2083,9 @@ packages: sass-formatter@0.7.9: resolution: {integrity: sha512-CWZ8XiSim+fJVG0cFLStwDvft1VI7uvXdCNJYXhDvowiv+DsbD1nXLiQ4zrE5UBvj5DWZJ93cwN0NX5PMsr1Pw==} + sax@1.4.1: + resolution: {integrity: sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==} + scheduler@0.23.2: resolution: {integrity: sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==} @@ -2115,6 +2130,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'} @@ -2133,6 +2153,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'} @@ -2632,6 +2655,12 @@ snapshots: - supports-color - vite + '@astrojs/sitemap@3.1.5': + dependencies: + sitemap: 7.1.2 + stream-replace-string: 2.0.0 + zod: 3.23.8 + '@astrojs/tailwind@5.1.0(astro@4.9.3(typescript@5.4.5))(tailwindcss@3.4.4)': dependencies: astro: 4.9.3(typescript@5.4.5) @@ -3243,6 +3272,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': @@ -3254,6 +3285,10 @@ snapshots: '@types/prop-types': 15.7.12 csstype: 3.1.3 + '@types/sax@1.2.7': + dependencies: + '@types/node': 17.0.45 + '@types/unist@2.0.10': {} '@types/unist@3.0.2': {} @@ -4999,6 +5034,8 @@ snapshots: dependencies: suf-log: 2.5.3 + sax@1.4.1: {} + scheduler@0.23.2: dependencies: loose-envify: 1.4.0 @@ -5060,6 +5097,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: {} @@ -5070,6 +5114,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 dfe8e0c..b9e950e 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -25,6 +25,7 @@ const pages: Array = [ href="https://fonts.googleapis.com/css2?family=Inconsolata:wght@200..900&display=swap" rel="preconnect" /> + RND diff --git a/src/pages/robots.txt.ts b/src/pages/robots.txt.ts new file mode 100644 index 0000000..9b1b6ec --- /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', + }, + }); +};