Added Astro sitemap feature.

This commit is contained in:
David Ball 2024-07-13 02:46:11 -04:00
parent 35a8bea436
commit 8f50e62c49
6 changed files with 79 additions and 5 deletions

View File

@ -1,4 +1,8 @@
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
// https://astro.build/config
export default defineConfig({});
export default defineConfig({
site: 'https://dashersupply.com',
integrations: [sitemap()],
});

49
package-lock.json generated
View File

@ -9,6 +9,7 @@
"version": "0.0.1",
"dependencies": {
"@astrojs/check": "^0.8.1",
"@astrojs/sitemap": "^3.1.6",
"astro": "^4.11.5",
"bootstrap": "^5.3.3",
"cheerio": "*",
@ -216,6 +217,17 @@
"node": "^18.17.1 || ^20.3.0 || >=21.0.0"
}
},
"node_modules/@astrojs/sitemap": {
"version": "3.1.6",
"resolved": "https://registry.npmjs.org/@astrojs/sitemap/-/sitemap-3.1.6.tgz",
"integrity": "sha512-1Qp2NvAzVImqA6y+LubKi1DVhve/hXXgFvB0szxiipzh7BvtuKe4oJJ9dXSqaubaTkt4nMa6dv6RCCAYeB6xaQ==",
"license": "MIT",
"dependencies": {
"sitemap": "^7.1.2",
"stream-replace-string": "^2.0.0",
"zod": "^3.23.8"
}
},
"node_modules/@astrojs/telemetry": {
"version": "3.1.0",
"license": "MIT",
@ -1990,6 +2002,12 @@
"node": ">= 8"
}
},
"node_modules/arg": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz",
"integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==",
"license": "MIT"
},
"node_modules/argparse": {
"version": "2.0.1",
"license": "Python-2.0"
@ -7051,6 +7069,31 @@
"version": "1.0.5",
"license": "MIT"
},
"node_modules/sitemap": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/sitemap/-/sitemap-7.1.2.tgz",
"integrity": "sha512-ARCqzHJ0p4gWt+j7NlU5eDlIO9+Rkr/JhPFZKKQ1l5GCus7rJH4UdrlVAh0xC/gDS/Qir2UMxqYNHtsKr2rpCw==",
"license": "MIT",
"dependencies": {
"@types/node": "^17.0.5",
"@types/sax": "^1.2.1",
"arg": "^5.0.0",
"sax": "^1.2.4"
},
"bin": {
"sitemap": "dist/cli.js"
},
"engines": {
"node": ">=12.0.0",
"npm": ">=5.6.0"
}
},
"node_modules/sitemap/node_modules/@types/node": {
"version": "17.0.45",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.45.tgz",
"integrity": "sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==",
"license": "MIT"
},
"node_modules/smart-buffer": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
@ -7156,6 +7199,12 @@
"stream-chain": "^2.2.5"
}
},
"node_modules/stream-replace-string": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/stream-replace-string/-/stream-replace-string-2.0.0.tgz",
"integrity": "sha512-TlnjJ1C0QrmxRNrON00JvaFFlNh5TTG00APw23j74ET7gkQpTASi6/L2fuiav8pzK715HXtUeClpBTw2NPSn6w==",
"license": "MIT"
},
"node_modules/string_decoder": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",

View File

@ -11,19 +11,20 @@
},
"dependencies": {
"@astrojs/check": "^0.8.1",
"@astrojs/sitemap": "^3.1.6",
"astro": "^4.11.5",
"bootstrap": "^5.3.3",
"cheerio": "*",
"crawlee": "^3.0.0",
"playwright": "*",
"markdown-it": "^14.0.0",
"markdown-it-attrs": "^4.1.6"
"markdown-it-attrs": "^4.1.6",
"playwright": "*"
},
"devDependencies": {
"@apify/tsconfig": "^0.1.0",
"@types/node": "^20.0.0",
"@types/markdown-it": "^14.1.1",
"@types/markdown-it-attrs": "^4.1.3",
"@types/node": "^20.0.0",
"tsx": "^4.4.0",
"typescript": "^5.5.2"
}

View File

@ -24,6 +24,7 @@ const { title } = Astro.props;
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Holtwood+One+SC&family=Caveat:wght@400..700&family=Protest+Strike&family=Charm:wght@400;700&family=Noto+Sans:ital,wght@0,100..900;1,100..900&family=Urbanist:ital,wght@0,100..900;1,100..900&family=Saira+Extra+Condensed&display=swap" rel="stylesheet">
<link rel="sitemap" href="/sitemap-index.xml" />
</head>
<body>
<slot />

View File

@ -35,6 +35,9 @@ import { ALL_CATEGORIES } from '../data/categories';
<p>
As an Amazon Associate I earn from qualifying purchases.
</p>
<p>
As an DoorDash Dasher I earn by completing deliveries.
</p>
<h2>Cookies?</h2>
<p>
We probably use them. I'm using Google Analytics and Cloudflare Analytics. I'm interested in knowing what everyone else likes.

16
src/pages/robots.txt.ts Normal file
View File

@ -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',
},
});
};