Skip to content

Commit

Permalink
Sort posts in RSS feed by reverse publish date
Browse files Browse the repository at this point in the history
  • Loading branch information
jb3 committed Aug 1, 2024
1 parent 3139787 commit 5061a3b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pages/feed.xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export async function GET(context: { site: string; }) {
// https://docs.astro.build/en/reference/api-reference/#contextsite
site: context.site,

items: blog.map((post) => ({
items: blog.sort((a, b) => {
return new Date(b.data.date).getTime() - new Date(a.data.date).getTime();
}).map((post) => ({
title: post.data.title,
pubDate: post.data.date,
description: post.data.blurb,
Expand Down

0 comments on commit 5061a3b

Please sign in to comment.