From 9444b1e98e1c07c267dbd8145e99460c6b9ac434 Mon Sep 17 00:00:00 2001 From: Cassidy Williams <1454517+cassidoo@users.noreply.github.com> Date: Fri, 5 Jan 2024 14:45:51 -0600 Subject: [PATCH] Fix RSS feed sorting and custom updated data --- src/pages/rss.xml.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js index 6241da7..417908b 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/rss.xml.js @@ -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: `${ + post.frontmatter.updated ? post.frontmatter.updated : "" + }`, }; }), });