diff --git a/src/pages/feed/feed.xml.js b/src/pages/feed/feed.xml.js index bd832219a..5a0b786b4 100644 --- a/src/pages/feed/feed.xml.js +++ b/src/pages/feed/feed.xml.js @@ -3,7 +3,15 @@ import { SITE_TITLE, SITE_DESCRIPTION } from "../../config"; const postImportResult = import.meta.glob("../notes/**/*.mdx", { eager: true, }); -const posts = Object.values(postImportResult); + +// Convert imported results to an array and sort by date +const posts = Object.values(postImportResult) + .sort((a, b) => { + const dateA = new Date(a.frontmatter.datePublished); + const dateB = new Date(b.frontmatter.datePublished); + return dateB - dateA; // Sort in descending order + }) + .slice(0, 30); // Get only the top 30 recent posts export const get = () => rss({