mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
Generate rss items with rss feed object
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import rss from "@astrojs/rss";
|
||||
import type { Frontmatter } from "@utils/types";
|
||||
import type { MarkdownInstance } from "astro";
|
||||
|
||||
const postImportResult = import.meta.glob<MarkdownInstance<Frontmatter>>(
|
||||
"../contents/*.md",
|
||||
{
|
||||
eager: true,
|
||||
}
|
||||
);
|
||||
const posts = Object.values(postImportResult);
|
||||
|
||||
export const get = () =>
|
||||
rss({
|
||||
title: import.meta.env.PUBLIC_SITE_TITLE,
|
||||
description: import.meta.env.PUBLIC_SITE_DESC,
|
||||
site: import.meta.env.SITE,
|
||||
items: posts.map(({ frontmatter }) => ({
|
||||
link: frontmatter.slug,
|
||||
title: frontmatter.title,
|
||||
description: frontmatter.description,
|
||||
pubDate: new Date(frontmatter.datetime),
|
||||
})),
|
||||
});
|
||||
Reference in New Issue
Block a user