Skip to content

fix(blog): sort blog by date#7722

Merged
aidankmcalister merged 1 commit intomainfrom
fix/blog-rss-feed-order
Mar 27, 2026
Merged

fix(blog): sort blog by date#7722
aidankmcalister merged 1 commit intomainfrom
fix/blog-rss-feed-order

Conversation

@aidankmcalister
Copy link
Member

@aidankmcalister aidankmcalister commented Mar 27, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Fixed RSS feed ordering to display blog posts in chronological order with newest items first.

@vercel
Copy link

vercel bot commented Mar 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blog Ready Ready Preview, Comment Mar 27, 2026 3:03pm
docs Ready Ready Preview, Comment Mar 27, 2026 3:03pm
eclipse Ready Ready Preview, Comment Mar 27, 2026 3:03pm
site Ready Ready Preview, Comment Mar 27, 2026 3:03pm

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 27, 2026

Walkthrough

The RSS generation function in apps/blog/src/lib/rss.ts has been modified to sort blog pages by date in descending chronological order (newest first) before generating the feed. Previously, pages were passed unsorted to the RSS generation logic.

Changes

Cohort / File(s) Summary
RSS Feed Sorting
apps/blog/src/lib/rss.ts
Modified getRSS() to copy and sort blog.getPages() results by data.date in descending order before passing to generateRSS. Maintains consistent function signature and metadata construction logic.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: sorting blog entries by date in the RSS feed generation logic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@argos-ci
Copy link

argos-ci bot commented Mar 27, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Mar 27, 2026, 3:09 PM

Copy link
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.

🧹 Nitpick comments (1)
apps/blog/src/lib/rss.ts (1)

7-10: Good fix for RSS feed ordering.

The sorting logic correctly orders posts by date descending (newest first), which is the expected convention for RSS feeds. Using the spread operator to copy the array before sorting is the right call—Array.prototype.sort() mutates in place, and you don't want to affect the original blog.getPages() result elsewhere.

One small observation: since the Zod schema uses z.coerce.date() (see apps/blog/source.config.ts:22), page.data.date is already a Date object. Wrapping it in new Date() again is technically redundant—though it's harmless and acts as defensive coding. The same pattern appears on line 23.

If you wanted to tighten this up:

♻️ Optional: Remove redundant Date wrapping
 const pages = [...blog.getPages()].sort(
   (a, b) =>
-    new Date(b.data.date).getTime() - new Date(a.data.date).getTime(),
+    b.data.date.getTime() - a.data.date.getTime(),
 );

And on line 23:

-    const date = new Date(page.data.date);
+    const date = page.data.date;

That said, the current implementation is perfectly functional and achieves the goal.

,

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/blog/src/lib/rss.ts` around lines 7 - 10, The comparator in the pages
sorting unnecessarily wraps already-coerced Date objects with new Date(); update
the sort callback used when creating pages (the spread of blog.getPages()) to
compare page.data.date and b.data.date directly (e.g., use b.data.date.getTime()
- a.data.date.getTime()) so you remove the redundant new Date() constructions
while preserving descending date order.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/blog/src/lib/rss.ts`:
- Around line 7-10: The comparator in the pages sorting unnecessarily wraps
already-coerced Date objects with new Date(); update the sort callback used when
creating pages (the spread of blog.getPages()) to compare page.data.date and
b.data.date directly (e.g., use b.data.date.getTime() - a.data.date.getTime())
so you remove the redundant new Date() constructions while preserving descending
date order.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2178f48d-ac07-4ac7-a647-31efdae35743

📥 Commits

Reviewing files that changed from the base of the PR and between c88461f and 16f2b99.

📒 Files selected for processing (1)
  • apps/blog/src/lib/rss.ts

@aidankmcalister aidankmcalister merged commit 3ff13d5 into main Mar 27, 2026
16 checks passed
@aidankmcalister aidankmcalister deleted the fix/blog-rss-feed-order branch March 27, 2026 15:10
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.

3 participants