diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js
index 7958586..27ae1fd 100644
--- a/src/pages/rss.xml.js
+++ b/src/pages/rss.xml.js
@@ -23,7 +23,7 @@ export const get = async () => {
link: getPermalink(post.slug, 'post'),
title: post.title,
description: post.description,
- pubDate: post.pubDate,
+ publishDate: post.publishDate,
})),
});
};
diff --git a/src/utils/frontmatter.js b/src/utils/frontmatter.js
new file mode 100644
index 0000000..560789a
--- /dev/null
+++ b/src/utils/frontmatter.js
@@ -0,0 +1,11 @@
+import getReadingTime from 'reading-time';
+import { toString } from 'mdast-util-to-string';
+
+export function remarkReadingTime() {
+ return function (tree, { data }) {
+ const text = toString(tree);
+ const readingTime = Math.ceil(getReadingTime(text).minutes);
+
+ data.astro.frontmatter.readingTime = readingTime;
+ };
+}
\ No newline at end of file
diff --git a/src/utils/posts.js b/src/utils/posts.js
index eb49cfd..9c133e7 100644
--- a/src/utils/posts.js
+++ b/src/utils/posts.js
@@ -1,13 +1,11 @@
-import getReadingTime from 'reading-time';
-
const getNormalizedPost = async (post) => {
- const { frontmatter, compiledContent, rawContent, file } = post;
+ const { frontmatter, Content, file } = post;
const ID = file.split('/').pop().split('.').shift();
return {
id: ID,
- pubDate: frontmatter.pubDate,
+ publishDate: frontmatter.publishDate,
draft: frontmatter.draft,
canonical: frontmatter.canonical,
@@ -15,19 +13,21 @@ const getNormalizedPost = async (post) => {
title: frontmatter.title,
description: frontmatter.description,
- body: compiledContent(),
image: frontmatter.image,
+ Content: Content,
+ // or 'body' in case you consume from API
+
excerpt: frontmatter.excerpt,
authors: frontmatter.authors,
category: frontmatter.category,
tags: frontmatter.tags,
- readingTime: Math.ceil(getReadingTime(rawContent()).minutes),
+ readingTime: frontmatter.readingTime,
};
};
const load = async function () {
- const posts = import.meta.glob('~/../data/blog/**/*.md', {
+ const posts = import.meta.glob(['~/../data/blog/**/*.md', '~/../data/blog/**/*.mdx'], {
eager: true,
});
@@ -37,7 +37,7 @@ const load = async function () {
});
const results = (await Promise.all(normalizedPosts))
- .sort((a, b) => new Date(b.pubDate).valueOf() - new Date(a.pubDate).valueOf())
+ .sort((a, b) => new Date(b.publishDate).valueOf() - new Date(a.publishDate).valueOf())
.filter((post) => !post.draft);
return results;
};