mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
fix: sort rss feed from latest to oldest (#38)
* Sorted the rss feed from latest to oldest. Which is crucial for RSS readers. * sorted rss using util func * refactor: remove redundant draft filter and update import positions --------- Co-authored-by: Saif71 <> Co-authored-by: Sat Naing <satnaingdev@gmail.com>
This commit is contained in:
committed by
GitHub
parent
69b39fecdf
commit
9e62b637e8
+11
-8
@@ -1,19 +1,22 @@
|
|||||||
import rss from "@astrojs/rss";
|
import rss from "@astrojs/rss";
|
||||||
import { getCollection } from "astro:content";
|
import { getCollection } from "astro:content";
|
||||||
import { SITE } from "@config";
|
import getSortedPosts from "@utils/getSortedPosts";
|
||||||
import slugify from "@utils/slugify";
|
import slugify from "@utils/slugify";
|
||||||
|
import { SITE } from "@config";
|
||||||
|
|
||||||
export async function get() {
|
export async function get() {
|
||||||
const posts = await getCollection("blog", ({ data }) => !data.draft);
|
const posts = await getCollection("blog");
|
||||||
|
const sortedPosts = getSortedPosts(posts);
|
||||||
return rss({
|
return rss({
|
||||||
title: SITE.title,
|
title: SITE.title,
|
||||||
description: SITE.desc,
|
description: SITE.desc,
|
||||||
site: SITE.website,
|
site: SITE.website,
|
||||||
items: posts.map(({ data }) => ({
|
items: sortedPosts
|
||||||
link: `posts/${slugify(data)}`,
|
.map(({ data }) => ({
|
||||||
title: data.title,
|
link: `posts/${slugify(data)}`,
|
||||||
description: data.description,
|
title: data.title,
|
||||||
pubDate: new Date(data.pubDatetime),
|
description: data.description,
|
||||||
})),
|
pubDate: new Date(data.pubDatetime),
|
||||||
|
})),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user