Skip to content

Commit

Permalink
Merge pull request #246 from anglepoised/limit-feed-posts
Browse files Browse the repository at this point in the history
feat: limit feed posts
  • Loading branch information
anglepoised authored Jan 10, 2024
2 parents 7c49916 + d5e7a12 commit 3a66729
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/pages/feed/feed.xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 3a66729

Please sign in to comment.