Fix RSS feed sorting and custom updated data

This commit is contained in:
Cassidy Williams
2024-01-05 14:45:51 -06:00
parent b493e967f0
commit 9444b1e98e

View File

@@ -3,7 +3,11 @@ import { SITE_TITLE, SITE_DESCRIPTION } from "../config";
let posts = Object.values(import.meta.glob("../posts/*.md", { eager: true }));
console.log(posts);
posts = posts.sort(
(a, b) =>
new Date(b.frontmatter.updated || b.frontmatter.added).valueOf() -
new Date(a.frontmatter.updated || a.frontmatter.added).valueOf()
);
export const get = () =>
rss({
@@ -17,9 +21,9 @@ export const get = () =>
pubDate: post.frontmatter.added,
description: post.frontmatter.description,
content: post.compiledContent(),
customData: {
updated: post.frontmatter?.updated,
},
customData: `<updated>${
post.frontmatter.updated ? post.frontmatter.updated : ""
}</updated>`,
};
}),
});