Skip to content

feat: add sitemap and robots generation#443

Merged
izadoesdev merged 2 commits into
mainfrom
feat/sitemap
Jul 23, 2025
Merged

feat: add sitemap and robots generation#443
izadoesdev merged 2 commits into
mainfrom
feat/sitemap

Conversation

@mezotv
Copy link
Copy Markdown
Collaborator

@mezotv mezotv commented Jul 23, 2025

Description

Adds the sitemap and robots generation to the project for google/seo reasons. I also quickly bumped nextjs.

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Performance improvement
  • Code refactoring
  • Tests

How Has This Been Tested?

Locally by navigating to the routes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have added screenshots if ui has been changed
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • New Features
    • Added automatic generation of robots.txt to control web crawler access and specify sitemap location.
    • Introduced dynamic sitemap generation, including both static pages and blog posts, to improve site indexing.
  • Chores
    • Updated the "next" package to version ^15.4.3 for improved stability and features.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jul 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
open-cut-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2025 5:35pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 23, 2025

Walkthrough

The changes introduce new modules for robots.txt and sitemap generation in the web application, add a constant for the site URL, and update the Next.js package version. The sitemap function dynamically includes both static and blog post routes, while robots.txt rules are explicitly defined for web crawlers.

Changes

Files/Paths Change Summary
apps/web/package.json Updated "next" package version from "^15.4.1" to "^15.4.3".
apps/web/src/app/robots.ts Added new module exporting a function that returns robots.txt rules for crawlers.
apps/web/src/app/sitemap.ts Added new async function to generate a sitemap with static and dynamic blog post routes.
apps/web/src/constants/site.ts Added new constant SITE_URL with the value "https://opencut.app".

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant App (Next.js)
    participant BlogData (getPosts)
    participant Constants (SITE_URL)

    Client->>App (robots.ts): Request /robots.txt
    App-->>Client: Respond with robots.txt rules (using SITE_URL)

    Client->>App (sitemap.ts): Request /sitemap.xml
    App->>BlogData: getPosts()
    BlogData-->>App: Blog posts data
    App->>Constants: Retrieve SITE_URL
    App-->>Client: Respond with sitemap including static and blog post URLs
Loading

Estimated code review effort

2 (~15 minutes)

Poem

In the warren of code, a sitemap is spun,
Robots.txt guides crawlers—oh what fun!
The site’s URL shines, a beacon so bright,
Next.js updated, everything’s right.
With routes for all bunnies, both static and new,
This web garden’s ready for visitors—woohoo!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jul 23, 2025

Deploy Preview for appcut ready!

Name Link
🔨 Latest commit 17d1336
🔍 Latest deploy log https://app.netlify.com/projects/appcut/deploys/68811d617d07fe0008fdd9fd
😎 Deploy Preview https://deploy-preview-443--appcut.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a 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 (3)
apps/web/src/constants/site.ts (1)

1-1: Consider using environment variables for deployment flexibility.

While the hardcoded URL works for production, consider using an environment variable to support different deployment environments (development, staging, production). This would improve maintainability and deployment flexibility.

-export const SITE_URL = "https://opencut.app";
+export const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || "https://opencut.app";
apps/web/src/app/robots.ts (1)

4-13: LGTM! Consider additional security paths.

The robots.txt implementation is well-structured and follows Next.js best practices. The disallowed paths appropriately block Next.js internals and application-specific routes.

Consider whether additional paths should be blocked for security:

  • /api/ routes (if they contain sensitive endpoints)
  • /admin/ or similar administrative paths
  • Any other private application routes
apps/web/src/app/sitemap.ts (1)

16-61: Review sitemap priorities and change frequencies.

The static routes configuration looks comprehensive, but some priorities and change frequencies could be optimized:

  1. Contributors page (line 26): changeFrequency: "daily" seems too frequent unless contributors are added daily
  2. Roadmap page (line 33): priority: 1 matches homepage priority - consider if this is intentional
  3. Why-not-capcut page (line 51): priority: 1 seems high for what appears to be a comparison page

Consider adjusting:

{
  url: `${SITE_URL}/contributors`,
  lastModified: new Date(),
-  changeFrequency: "daily",
+  changeFrequency: "monthly",
  priority: 0.5,
},
{
  url: `${SITE_URL}/roadmap`,
  lastModified: new Date(),
  changeFrequency: "weekly",
-  priority: 1,
+  priority: 0.8,
},
{
  url: `${SITE_URL}/why-not-capcut`,
  lastModified: new Date(),
  changeFrequency: "yearly",
-  priority: 1,
+  priority: 0.7,
},
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 41a78b4 and 17d1336.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • apps/web/package.json (1 hunks)
  • apps/web/src/app/robots.ts (1 hunks)
  • apps/web/src/app/sitemap.ts (1 hunks)
  • apps/web/src/constants/site.ts (1 hunks)
⏰ 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). (4)
  • GitHub Check: Redirect rules - appcut
  • GitHub Check: Header rules - appcut
  • GitHub Check: Pages changed - appcut
  • GitHub Check: build (windows-latest)
🔇 Additional comments (2)
apps/web/package.json (1)

45-45: Next.js ^15.4.3 Verified and Ready

  • Confirmed version 15.4.3 exists on npm and is the current latest release.
  • No security advisories or breaking changes reported for this patch.
  • Includes the metadata route type enhancements as expected.

No further action required.

apps/web/src/app/sitemap.ts (1)

8-14: We’ve confirmed that getPosts() is implemented in apps/web/src/lib/blog-query.ts as an async function calling fetchFromMarble, which already throws on non-OK responses. No additional error handling is needed here.

No changes required.

Comment on lines +5 to +14
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const data = await getPosts();

const postPages: MetadataRoute.Sitemap =
data?.posts?.map((post) => ({
url: `${SITE_URL}/blog/${post.slug}`,
lastModified: new Date(post.publishedAt),
changeFrequency: "weekly",
priority: 0.8,
})) ?? [];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for blog posts fetching.

The sitemap generation looks well-implemented, but consider adding error handling for the getPosts() call to ensure the sitemap still generates even if blog posts can't be fetched.

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
-  const data = await getPosts();
+  let data;
+  try {
+    data = await getPosts();
+  } catch (error) {
+    console.error('Failed to fetch posts for sitemap:', error);
+    data = null;
+  }

  const postPages: MetadataRoute.Sitemap =
    data?.posts?.map((post) => ({
📝 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.

Suggested change
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const data = await getPosts();
const postPages: MetadataRoute.Sitemap =
data?.posts?.map((post) => ({
url: `${SITE_URL}/blog/${post.slug}`,
lastModified: new Date(post.publishedAt),
changeFrequency: "weekly",
priority: 0.8,
})) ?? [];
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
- const data = await getPosts();
+ let data;
+ try {
+ data = await getPosts();
+ } catch (error) {
+ console.error('Failed to fetch posts for sitemap:', error);
+ data = null;
+ }
const postPages: MetadataRoute.Sitemap =
data?.posts?.map((post) => ({
url: `${SITE_URL}/blog/${post.slug}`,
lastModified: new Date(post.publishedAt),
changeFrequency: "weekly",
priority: 0.8,
})) ?? [];
🤖 Prompt for AI Agents
In apps/web/src/app/sitemap.ts around lines 5 to 14, the getPosts() call lacks
error handling, which could cause the sitemap generation to fail if fetching
posts errors out. Wrap the getPosts() call in a try-catch block, and in the
catch block, handle the error gracefully by logging it or returning an empty
array for posts so the sitemap can still generate without blog post URLs.

Copy link
Copy Markdown
Collaborator

@izadoesdev izadoesdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@izadoesdev izadoesdev merged commit 81ad5c1 into main Jul 23, 2025
10 checks passed
@izadoesdev izadoesdev deleted the feat/sitemap branch July 23, 2025 17:46
zstar1003 pushed a commit to zstar1003/FlashCut that referenced this pull request Jan 28, 2026
feat: add sitemap and robots generation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants