fix: sort rss feed by date

This commit is contained in:
Jacky Zhao 2023-11-11 12:08:54 -08:00
parent 6659182eef
commit cf32895001

View File

@ -6,6 +6,7 @@ import { FilePath, FullSlug, SimpleSlug, simplifySlug } from "../../util/path"
import { QuartzEmitterPlugin } from "../types"
import { toHtml } from "hast-util-to-html"
import path from "path"
import { byDateAndAlphabetical } from "../../components/PageList"
export type ContentIndex = Map<FullSlug, ContentDetails>
export type ContentDetails = {
@ -59,6 +60,7 @@ function generateRSSFeed(cfg: GlobalConfiguration, idx: ContentIndex, limit?: nu
</item>`
const items = Array.from(idx)
.sort((a, b) => byDateAndAlphabetical(cfg)(a[1], b[1]))
.map(([slug, content]) => createURLEntry(simplifySlug(slug), content))
.slice(0, limit ?? idx.size)
.join("")