feat: add sitemap filtering option#7368
Conversation
📝 WalkthroughWalkthroughThis PR adds a ChangesSitemap Filter Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Bundle Size Benchmarks
Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/start-plugin-core/tests/build-sitemap.test.ts (1)
127-141: 💤 Low valueOptional: consolidate page setup inside
makeStartConfigto match the rest of the suite.Line 136 mutates
startConfig.pagesexternally while every other test passes pages throughmakeStartConfig. ThemakeStartConfighelper already accepts apagesoverride, so this can be unified.♻️ Proposed refactor
- it('applies custom filter function', () => { - const startConfig = makeStartConfig({ - sitemap: { - enabled: true, - host: 'https://example.com', - outputPath: 'sitemap.xml', - filter: (page: any) => page.path !== '/hidden', - }, - }) - startConfig.pages = [{ path: '/visible' }, { path: '/hidden' }] - buildSitemap({ startConfig, publicDir: '/dist' }) + it('applies custom filter function', () => { + const startConfig = makeStartConfig({ + pages: [{ path: '/visible' }, { path: '/hidden' }], + sitemap: { + enabled: true, + host: 'https://example.com', + outputPath: 'sitemap.xml', + filter: (page: any) => page.path !== '/hidden', + }, + }) + buildSitemap({ startConfig, publicDir: '/dist' })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/start-plugin-core/tests/build-sitemap.test.ts` around lines 127 - 141, The test mutates startConfig.pages after creation; instead pass pages into makeStartConfig to match other tests—update the test that calls makeStartConfig({ sitemap: {...} }) so the pages array (e.g., [{ path: '/visible' }, { path: '/hidden' }]) is provided as the pages override to makeStartConfig, remove the external assignment to startConfig.pages, and leave the subsequent call to buildSitemap and assertions unchanged (references: makeStartConfig, buildSitemap).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/start-plugin-core/src/build-sitemap.ts`:
- Around line 51-54: The current Array.filter predicate calls the user-provided
filter synchronously so async filters are ignored; change the predicate to be
async and await the filter result, e.g. make the callback async and replace the
check `if (filter && !filter(page)) return false` with `if (filter &&
!Boolean(await filter(page))) return false`, and add a JSDoc note to the
`filter` parameter (and update any schema/type for `filter` if present) to
clarify it may be async and should resolve to a truthy/falsey value; use the
same `filter` identifier in the surrounding function so the change is localized.
---
Nitpick comments:
In `@packages/start-plugin-core/tests/build-sitemap.test.ts`:
- Around line 127-141: The test mutates startConfig.pages after creation;
instead pass pages into makeStartConfig to match other tests—update the test
that calls makeStartConfig({ sitemap: {...} }) so the pages array (e.g., [{
path: '/visible' }, { path: '/hidden' }]) is provided as the pages override to
makeStartConfig, remove the external assignment to startConfig.pages, and leave
the subsequent call to buildSitemap and assertions unchanged (references:
makeStartConfig, buildSitemap).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 23b58d2f-5746-4ef0-9b11-c0c010f7c6f3
📒 Files selected for processing (5)
docs/start/framework/react/guide/seo.mddocs/start/framework/solid/guide/seo.mdpackages/start-plugin-core/src/build-sitemap.tspackages/start-plugin-core/src/schema.tspackages/start-plugin-core/tests/build-sitemap.test.ts
Pre-rendering with link crawling can pick up irrelevant pages not intended for the sitemap. Just as
prerenderhas afilteroption to exclude certain pages, I propose the same forsitemap.Example intended usage
Summary by CodeRabbit
New Features
Documentation
Tests