Skip to content

Commit 3d2673b

Browse files
feat: implement sitemap generation in TypeScript and remove XML file (#6206)
Co-authored-by: daniel-lxs <[email protected]> Co-authored-by: Daniel <[email protected]>
1 parent e5d93f2 commit 3d2673b

File tree

8 files changed

+98
-10
lines changed

8 files changed

+98
-10
lines changed

apps/web-roo-code/.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
66
# Basin Form Endpoint for Static Form Submissions
77
# Replace this with your actual Basin form endpoint (e.g., https://usebasin.com/f/your-form-id)
88
NEXT_PUBLIC_BASIN_ENDPOINT=https://usebasin.com/f/your-form-id-here
9+
10+
# Site URL Configuration
11+
# Used for generating absolute URLs in sitemap and other contexts
12+
NEXT_PUBLIC_SITE_URL=https://roocode.com

apps/web-roo-code/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ yarn-error.log*
4040
# typescript
4141
*.tsbuildinfo
4242
next-env.d.ts
43+
44+
# generated files
45+
/public/sitemap*.xml
46+
/public/robots.txt

apps/web-roo-code/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
enable-pre-post-scripts=true
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/** @type {import('next-sitemap').IConfig} */
2+
module.exports = {
3+
siteUrl: process.env.NEXT_PUBLIC_SITE_URL || 'https://roocode.com',
4+
generateRobotsTxt: true,
5+
generateIndexSitemap: false, // We don't need index sitemap for a small site
6+
changefreq: 'monthly',
7+
priority: 0.7,
8+
sitemapSize: 5000,
9+
exclude: [
10+
'/api/*',
11+
'/server-sitemap-index.xml',
12+
'/404',
13+
'/500',
14+
'/_not-found',
15+
],
16+
robotsTxtOptions: {
17+
policies: [
18+
{
19+
userAgent: '*',
20+
allow: '/',
21+
},
22+
],
23+
additionalSitemaps: [
24+
// Add any additional sitemaps here if needed in the future
25+
],
26+
},
27+
// Custom transform function to set specific priorities and change frequencies
28+
transform: async (config, path) => {
29+
// Set custom priority for specific pages
30+
let priority = config.priority;
31+
let changefreq = config.changefreq;
32+
33+
if (path === '/') {
34+
priority = 1.0;
35+
changefreq = 'yearly';
36+
} else if (path === '/enterprise' || path === '/evals') {
37+
priority = 0.8;
38+
changefreq = 'monthly';
39+
} else if (path === '/privacy' || path === '/terms') {
40+
priority = 0.5;
41+
changefreq = 'yearly';
42+
}
43+
44+
return {
45+
loc: path,
46+
changefreq,
47+
priority,
48+
lastmod: config.autoLastmod ? new Date().toISOString() : undefined,
49+
alternateRefs: config.alternateRefs ?? [],
50+
};
51+
},
52+
additionalPaths: async (config) => {
53+
// Add any additional paths that might not be automatically discovered
54+
// This is useful for dynamic routes or API-generated pages
55+
return [];
56+
},
57+
};

apps/web-roo-code/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"check-types": "tsc --noEmit",
88
"dev": "next dev",
99
"build": "next build",
10+
"postbuild": "next-sitemap --config next-sitemap.config.cjs",
1011
"start": "next start",
1112
"clean": "rimraf .next .turbo"
1213
},
@@ -42,6 +43,7 @@
4243
"@types/react": "^18.3.23",
4344
"@types/react-dom": "^18.3.7",
4445
"autoprefixer": "^10.4.21",
46+
"next-sitemap": "^4.2.3",
4547
"postcss": "^8.5.4",
4648
"tailwindcss": "^3.4.17"
4749
}

apps/web-roo-code/src/app/sitemap.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

knip.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"src/activate/**",
88
"src/workers/countTokens.ts",
99
"src/extension.ts",
10-
"scripts/**"
10+
"scripts/**",
11+
"apps/web-roo-code/next-sitemap.config.cjs"
1112
],
1213
"workspaces": {
1314
"src": {

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)