Skip to content

Commit 1d49f5b

Browse files
authored
[Chore] Add redirect for sitemap + customize behavior (#16163)
* [Chore] Add redirect for sitemap * Added lastmod to sitemap entries * Apply suggestions from code review
1 parent f85e0d1 commit 1d49f5b

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

astro.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import rehypeAutolinkHeadings from 'rehype-autolink-headings';
1010
import { h } from 'hastscript';
1111
import { readdir } from "fs/promises";
1212
import icon from "astro-icon";
13+
import sitemap from '@astrojs/sitemap';
1314

1415
async function autogenSections() {
1516
const sections = (
@@ -136,5 +137,11 @@ export default defineConfig({
136137
}),
137138
liveCode({ layout: "~/components/live-code/Layout.astro" }),
138139
icon(),
140+
sitemap({
141+
serialize(item) {
142+
item.lastmod = new Date();
143+
return item;
144+
},
145+
}),
139146
],
140147
});

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@astro-community/astro-embed-youtube": "^0.5.2",
1515
"@astrojs/check": "^0.9.2",
1616
"@astrojs/rss": "^4.0.7",
17+
"@astrojs/sitemap": "^3.1.6",
1718
"@astrojs/starlight": "^0.25.5",
1819
"@astrojs/starlight-docsearch": "^0.1.1",
1920
"@astrojs/starlight-tailwind": "^2.0.3",

public/_redirects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/zero-trust/ /products/?product-group=Cloudflare+One 301
44
/dashboarding-landing/ / 301
55
/tutorials/ /search/?content_type%5B0%5D=Tutorial 301
6+
/sitemap.xml /sitemap-index.xml
67

78
# 1dot1_redirect
89
/1.1.1.1/1.1.1.1-for-families/ /1.1.1.1/setup/ 301

0 commit comments

Comments
 (0)