Create dynamic sitemap with static and agent routes#249
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
20b0f18 to
112ec5b
Compare
There was a problem hiding this comment.
Pull request overview
This PR enhances SEO by converting the static sitemap to a dynamic one that includes both static routes and agent-specific routes generated from markdown files.
Changes:
- Made sitemap function async to support dynamic data fetching
- Added static routes from PATHS constants with priority-based ranking (home=1, static=0.8)
- Added dynamic agent routes by fetching RFS data and generating URLs with priority 0.7
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/app/sitemap.ts
Outdated
| export default async function sitemap(): Promise<MetadataRoute.Sitemap> { | ||
| const staticRoutes = getStaticRoutes(); | ||
| const agentRoutes = await getAgentRoutes(); | ||
|
|
||
| return [...staticRoutes, ...agentRoutes]; |
There was a problem hiding this comment.
The sitemap function doesn't include error handling for the async getAllRFSData() call. If this function fails (e.g., due to file system errors or invalid markdown), the entire sitemap generation will fail, potentially breaking the site's /sitemap.xml endpoint. Consider adding a try-catch block to handle errors gracefully, either by logging and returning only static routes, or by ensuring getAllRFSData has its own error handling. The pattern in src/app/agents/[slug]/page.tsx (lines 20-86) shows similar async data fetching with try-catch error handling.
There was a problem hiding this comment.
getAllRFSData reads local markdown files that are committed to the repo. Any failures (missing files, invalid frontmatter) would surface at build time when Next.js pre-renders the agent pages, well before the sitemap is generated. So a try-catch here wouldn't add meaningful resilience in practice.
3e0c29f to
ee5cb8c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📝 Description
This PR implements a dynamic sitemap that includes both static routes and dynamically generated agent routes. This improves SEO by ensuring all pages are discoverable by search engines.
NOTE: Will add a
lastUpdatedfield to the/agents[slug]pages in a separate PR.Fixes: #248
🛠️ Key Changes
📌 To-Do Before Merging
🧪 How to Test
📸 Screenshots
🔖 Resources