feat(docs): add dynamic sitemap.xml generation#5728
feat(docs): add dynamic sitemap.xml generation#5728kiloconnect[bot] wants to merge 3 commits intomainfrom
Conversation
- Add API endpoint at /api/sitemap.xml that dynamically generates sitemap - Add rewrite rule to serve sitemap at /sitemap.xml - Include all markdown pages with lastmod dates and priority - Add comprehensive tests for sitemap generation
|
Code Review SummaryStatus: 3 Issues Found | Recommendation: Address before merge Overview
Fix these issues in Kilo Cloud Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (3 files)
|
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
| </url>`) | ||
|
|
||
| for (const filePath of markdownFiles) { | ||
| const urlPath = filePathToUrlPath(filePath, pagesDir) |
There was a problem hiding this comment.
WARNING: Potential duplicate homepage entry in sitemap
findMarkdownFiles() will include pages/index.md, and filePathToUrlPath() maps it to /. The loop will then emit a second homepage-like URL (typically https://kilo.ai/docs/) in addition to the explicit homepage entry (https://kilo.ai/docs). Consider skipping urlPath === "/" in the loop or excluding the root index.md from markdownFiles.
| </url>`) | ||
|
|
||
| for (const filePath of markdownFiles) { | ||
| const urlPath = filePathToUrlPath(filePath, pagesDir) |
There was a problem hiding this comment.
WARNING: Sitemap likely includes a duplicate homepage entry (/docs and /docs/)
This endpoint always adds the homepage manually, but markdownFiles will also include pages/index.md. filePathToUrlPath() converts that file to urlPath === "/", so the loop will add a second URL with a trailing slash (${SITE_URL}/). That can create duplicate canonical entries in the sitemap.
Consider skipping entries where urlPath === "/" (or filtering out the root index.md before iterating), and adding a test assertion to catch the trailing-slash variant.
Summary
This PR adds dynamic sitemap.xml generation for the Kilo Code documentation site.
Changes
pages/api/sitemap.xml.ts): Dynamically generates a sitemap by scanning all markdown files in the pages directorynext.config.js: Routes/sitemap.xmlto the API endpoint__tests__/sitemap.spec.ts): Validates sitemap generation, XML structure, and error handlingFeatures
lastmoddates based on file modification times/apidirectoryHow it works
The sitemap is served at
https://kilo.ai/docs/sitemap.xmland updates automatically whenever documentation content changes. No manual regeneration is needed.Built for Brendan by Kilo for Slack