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:
Salman Hossain Saif
2023-03-17 12:44:10 +06:00
committed by GitHub
parent 69b39fecdf
commit 9e62b637e8
+11 -8
View File
@@ -1,19 +1,22 @@
import rss from "@astrojs/rss";
import { getCollection } from "astro:content";
import { SITE } from "@config";
import getSortedPosts from "@utils/getSortedPosts";
import slugify from "@utils/slugify";
import { SITE } from "@config";
export async function get() {
const posts = await getCollection("blog", ({ data }) => !data.draft);
const posts = await getCollection("blog");
const sortedPosts = getSortedPosts(posts);
return rss({
title: SITE.title,
description: SITE.desc,
site: SITE.website,
items: posts.map(({ data }) => ({
link: `posts/${slugify(data)}`,
title: data.title,
description: data.description,
pubDate: new Date(data.pubDatetime),
})),
items: sortedPosts
.map(({ data }) => ({
link: `posts/${slugify(data)}`,
title: data.title,
description: data.description,
pubDate: new Date(data.pubDatetime),
})),
});
}