-
Notifications
You must be signed in to change notification settings - Fork 7
Feat: Sitemap #422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v0-2
Are you sure you want to change the base?
Feat: Sitemap #422
Conversation
|
Note
|
| Cohort / File(s) | Summary |
|---|---|
New Sitemap Generator src/app/sitemap.ts |
Exports default sitemap() function returning MetadataRoute.Sitemap. Collects sources (mainSource, selfHostingSource, platformSource, guideSource, openApiSource, developingSource), calls each source's getPages(), and maps pages to entries with url (https://docs.logchimp.codecarrot.net + page.url) and lastModified (current ISO timestamp). |
Sequence Diagram(s)
sequenceDiagram
participant NextJS as Next.js
participant SitemapFn as sitemap()
participant Sources as PageSources
participant Output as SitemapArray
NextJS->>SitemapFn: Request sitemap
activate SitemapFn
SitemapFn->>SitemapFn: build sources list
loop for each source
SitemapFn->>Sources: getPages()
activate Sources
Sources-->>SitemapFn: pages[]
deactivate Sources
SitemapFn->>SitemapFn: map pages -> { url, lastModified }
end
SitemapFn-->>Output: return MetadataRoute.Sitemap
deactivate SitemapFn
Output-->>NextJS: sitemap metadata
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
- Check
getPages()availability and return shape for each source. - Verify domain concatenation and handling of leading/trailing slashes in
page.url. - Consider whether
lastModifiedshould use page-specific metadata instead of current timestamp.
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'Feat: Sitemap' clearly relates to the main change, which adds a new sitemap generator. It is concise and specific. |
| Linked Issues check | ✅ Passed | The PR successfully implements sitemap generation by creating src/app/sitemap.ts that aggregates pages from multiple sources and exports a proper MetadataRoute.Sitemap function, addressing issue #313. |
| Out of Scope Changes check | ✅ Passed | All changes are directly related to sitemap generation with no out-of-scope modifications identified. |
✨ Finishing touches
- 📝 Generate docstrings
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
feat/sitemap
Tip
📝 Customizable high-level summaries are now available!
You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
- Provide custom instructions to shape the summary (bullet lists, tables, contributor stats, etc.).
- Use
high_level_summary_in_walkthroughto move the summary from the description to the walkthrough section.
Example:
"Create a concise high-level summary as a bullet-point list. Then include a Markdown table showing lines added and removed by each contributing author."
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 @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/app/sitemap.ts (1)
24-24: Consider using actual content modification dates.Using the current timestamp for all pages means every page appears to have been modified at build time, which doesn't help search engines prioritize fresh content. If the page sources expose actual modification dates (e.g., from file metadata or frontmatter), consider using those instead.
Example approach if sources provide modification dates:
- lastModified: new Date().toISOString(), + lastModified: page.data?.lastModified || new Date().toISOString(),Note: This assumes the page data includes a
lastModifiedfield. If not available, the current approach is acceptable as a fallback.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/app/sitemap.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/app/sitemap.ts (1)
src/lib/source.ts (6)
mainSource(14-22)selfHostingSource(24-32)platformSource(34-42)guideSource(44-52)openApiSource(54-60)developingSource(62-70)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: vercel_deployment
🔇 Additional comments (2)
src/app/sitemap.ts (2)
1-9: LGTM!The imports are well-organized and appropriate for implementing a Next.js sitemap generator.
11-19: LGTM!The function signature correctly implements the Next.js sitemap convention, and aggregating all sources in an array is clean and maintainable.
|
|
||
| return sources.flatMap((s) => | ||
| s.getPages().map((page) => ({ | ||
| url: `https://docs.logchimp.codecarrot.net${page.url}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move hardcoded domain to environment variable.
The hardcoded domain https://docs.logchimp.codecarrot.net creates maintenance issues and will break in development or staging environments.
Apply this diff to use an environment variable:
- url: `https://docs.logchimp.codecarrot.net${page.url}`,
+ url: `${process.env.NEXT_PUBLIC_SITE_URL || 'https://docs.logchimp.codecarrot.net'}${page.url}`,Then add NEXT_PUBLIC_SITE_URL to your .env files for different environments.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| url: `https://docs.logchimp.codecarrot.net${page.url}`, | |
| url: `${process.env.NEXT_PUBLIC_SITE_URL || 'https://docs.logchimp.codecarrot.net'}${page.url}`, |
🤖 Prompt for AI Agents
In src/app/sitemap.ts around line 23, replace the hardcoded URL prefix
`https://docs.logchimp.codecarrot.net` with a value read from the environment
(e.g. process.env.NEXT_PUBLIC_SITE_URL) and fall back to a sensible default for
local dev if needed; update the code to build each url as
`${siteUrl}${page.url}` where siteUrl is read once from
process.env.NEXT_PUBLIC_SITE_URL (validate it or throw/console.warn if missing)
and add NEXT_PUBLIC_SITE_URL to your .env files for dev/staging/production.
This reverts commit 132572f.
85c362f to
e014178
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/app/sitemap.ts (1)
23-23: Move hardcoded domain to environment variable.The hardcoded domain creates maintenance issues and will break in non-production environments. This was previously flagged in the last review.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/app/sitemap.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/app/sitemap.ts (1)
src/lib/source.ts (6)
mainSource(14-22)selfHostingSource(24-32)platformSource(34-42)guideSource(44-52)openApiSource(54-60)developingSource(62-70)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: vercel_deployment
🔇 Additional comments (2)
src/app/sitemap.ts (2)
1-9: LGTM!Imports are clean and properly structured for Next.js 15 sitemap generation.
11-19: LGTM!The function signature correctly implements Next.js sitemap generation, and aggregating sources into an array is a clean approach.
| return sources.flatMap((s) => | ||
| s.getPages().map((page) => ({ | ||
| url: `https://docs.logchimp.codecarrot.net${page.url}`, | ||
| lastModified: new Date().toISOString(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use actual modification dates instead of current timestamp.
Setting lastModified to the current time for all pages defeats its purpose and causes search engines to unnecessarily re-crawl all content on every sitemap generation.
Consider these alternatives:
- Use the build timestamp (constant across all pages in a build):
+const buildTime = new Date().toISOString();
+
export default function sitemap(): MetadataRoute.Sitemap {
const sources = [
// ...
];
return sources.flatMap((s) =>
s.getPages().map((page) => ({
url: `https://docs.logchimp.codecarrot.net${page.url}`,
- lastModified: new Date().toISOString(),
+ lastModified: buildTime,
})),
);
}- Better: If pages expose modification metadata, use it:
lastModified: page.lastModified || buildTime,- Best: Use git commit dates for each content file (requires integration with your content source).
🤖 Prompt for AI Agents
In src/app/sitemap.ts around line 24, the sitemap currently sets lastModified to
new Date().toISOString() which stamps every page with the current time; change
this to use a stable build-level timestamp or real content modification dates
instead: create a buildTime constant at build/startup and use lastModified:
page.lastModified || buildTime when page metadata provides a modification date,
and if available integrate file/git commit dates per page for the most accurate
value; ensure lastModified is an ISO string and fall back to buildTime only when
no page-specific date exists.
Closes #313
Summary by CodeRabbit