feat: implement sitemap generation in TypeScript and remove XML file (#6206)

Co-authored-by: daniel-lxs <ricciodaniel98@gmail.com>
Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
This commit is contained in:
Abdullah Hilson 2025-08-14 18:53:16 +03:00 committed by GitHub
parent e5d93f2bca
commit 3d2673bb28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 98 additions and 10 deletions

View file

@ -6,3 +6,7 @@ NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
# Basin Form Endpoint for Static Form Submissions
# Replace this with your actual Basin form endpoint (e.g., https://usebasin.com/f/your-form-id)
NEXT_PUBLIC_BASIN_ENDPOINT=https://usebasin.com/f/your-form-id-here
# Site URL Configuration
# Used for generating absolute URLs in sitemap and other contexts
NEXT_PUBLIC_SITE_URL=https://roocode.com

View file

@ -40,3 +40,7 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
# generated files
/public/sitemap*.xml
/public/robots.txt

1
apps/web-roo-code/.npmrc Normal file
View file

@ -0,0 +1 @@
enable-pre-post-scripts=true

View file

@ -0,0 +1,57 @@
/** @type {import('next-sitemap').IConfig} */
module.exports = {
siteUrl: process.env.NEXT_PUBLIC_SITE_URL || 'https://roocode.com',
generateRobotsTxt: true,
generateIndexSitemap: false, // We don't need index sitemap for a small site
changefreq: 'monthly',
priority: 0.7,
sitemapSize: 5000,
exclude: [
'/api/*',
'/server-sitemap-index.xml',
'/404',
'/500',
'/_not-found',
],
robotsTxtOptions: {
policies: [
{
userAgent: '*',
allow: '/',
},
],
additionalSitemaps: [
// Add any additional sitemaps here if needed in the future
],
},
// Custom transform function to set specific priorities and change frequencies
transform: async (config, path) => {
// Set custom priority for specific pages
let priority = config.priority;
let changefreq = config.changefreq;
if (path === '/') {
priority = 1.0;
changefreq = 'yearly';
} else if (path === '/enterprise' || path === '/evals') {
priority = 0.8;
changefreq = 'monthly';
} else if (path === '/privacy' || path === '/terms') {
priority = 0.5;
changefreq = 'yearly';
}
return {
loc: path,
changefreq,
priority,
lastmod: config.autoLastmod ? new Date().toISOString() : undefined,
alternateRefs: config.alternateRefs ?? [],
};
},
additionalPaths: async (config) => {
// Add any additional paths that might not be automatically discovered
// This is useful for dynamic routes or API-generated pages
return [];
},
};

View file

@ -7,6 +7,7 @@
"check-types": "tsc --noEmit",
"dev": "next dev",
"build": "next build",
"postbuild": "next-sitemap --config next-sitemap.config.cjs",
"start": "next start",
"clean": "rimraf .next .turbo"
},
@ -42,6 +43,7 @@
"@types/react": "^18.3.23",
"@types/react-dom": "^18.3.7",
"autoprefixer": "^10.4.21",
"next-sitemap": "^4.2.3",
"postcss": "^8.5.4",
"tailwindcss": "^3.4.17"
}

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://roocode.com/</loc>
<lastmod>2025-03-13T22:26:09Z</lastmod>
<changefreq>yearly</changefreq>
<priority>1.0</priority>
</url>
</urlset>

View file

@ -7,7 +7,8 @@
"src/activate/**",
"src/workers/countTokens.ts",
"src/extension.ts",
"scripts/**"
"scripts/**",
"apps/web-roo-code/next-sitemap.config.cjs"
],
"workspaces": {
"src": {

28
pnpm-lock.yaml generated
View file

@ -342,6 +342,9 @@ importers:
autoprefixer:
specifier: ^10.4.21
version: 10.4.21(postcss@8.5.4)
next-sitemap:
specifier: ^4.2.3
version: 4.2.3(next@15.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1))
postcss:
specifier: ^8.5.4
version: 8.5.4
@ -1532,6 +1535,9 @@ packages:
'@chevrotain/utils@11.0.3':
resolution: {integrity: sha512-YslZMgtJUyuMbZ+aKvfF3x1f5liK4mWNxghFRv7jqRR9C3R3fAOGTTKvxXDa2Y1s9zSbcpuO0cAxDYsc9SrXoQ==}
'@corex/deepmerge@4.0.43':
resolution: {integrity: sha512-N8uEMrMPL0cu/bdboEWpQYb/0i2K5Qn8eCsxzOmxSggJbbQte7ljMRoXm917AbntqTGOzdTu+vP3KOOzoC70HQ==}
'@csstools/color-helpers@5.0.2':
resolution: {integrity: sha512-JqWH1vsgdGcw2RR6VliXXdA0/59LttzlU8UlRT/iUUsEeWfYq8I+K0yhihEUTTHLRm1EXvpsCx3083EU15ecsA==}
engines: {node: '>=18'}
@ -2132,6 +2138,9 @@ packages:
'@neon-rs/load@0.0.4':
resolution: {integrity: sha512-kTPhdZyTQxB+2wpiRcFWrDcejc4JI6tkPuS7UZCG4l6Zvc5kU/gGQ/ozvHTh1XR5tS+UlfAfGuPajjzQjCiHCw==}
'@next/env@13.5.11':
resolution: {integrity: sha512-fbb2C7HChgM7CemdCY+y3N1n8pcTKdqtQLbC7/EQtPdLvlMUT9JX/dBYl8MMZAtYG4uVMyPFHXckb68q/NRwqg==}
'@next/env@15.2.5':
resolution: {integrity: sha512-uWkCf9C8wKTyQjqrNk+BA7eL3LOQdhL+xlmJUf2O85RM4lbzwBwot3Sqv2QGe/RGnc3zysIf1oJdtq9S00pkmQ==}
@ -7485,6 +7494,13 @@ packages:
resolution: {integrity: sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==}
engines: {node: '>= 0.4.0'}
next-sitemap@4.2.3:
resolution: {integrity: sha512-vjdCxeDuWDzldhCnyFCQipw5bfpl4HmZA7uoo3GAaYGjGgfL4Cxb1CiztPuWGmS+auYs7/8OekRS8C2cjdAsjQ==}
engines: {node: '>=14.18'}
hasBin: true
peerDependencies:
next: '*'
next-themes@0.4.6:
resolution: {integrity: sha512-pZvgD5L0IEvX5/9GWyHMf3m8BKiVQwsCMHfoFosXtXBMnaS0ZnIJ9ST4b4NqLVKDEm8QBxoNNGNaBv2JNF6XNA==}
peerDependencies:
@ -10821,6 +10837,8 @@ snapshots:
'@chevrotain/utils@11.0.3': {}
'@corex/deepmerge@4.0.43': {}
'@csstools/color-helpers@5.0.2': {}
'@csstools/css-calc@2.1.4(@csstools/css-parser-algorithms@3.0.5(@csstools/css-tokenizer@3.0.4))(@csstools/css-tokenizer@3.0.4)':
@ -11418,6 +11436,8 @@ snapshots:
'@neon-rs/load@0.0.4':
optional: true
'@next/env@13.5.11': {}
'@next/env@15.2.5': {}
'@next/eslint-plugin-next@15.3.2':
@ -17502,6 +17522,14 @@ snapshots:
netmask@2.0.2: {}
next-sitemap@4.2.3(next@15.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)):
dependencies:
'@corex/deepmerge': 4.0.43
'@next/env': 13.5.11
fast-glob: 3.3.3
minimist: 1.2.8
next: 15.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
next-themes@0.4.6(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
dependencies:
react: 18.3.1