Merge pull request #733 from ttys3/fix-rss-last-build-date

fix: use sort posts for rss, fix lastBuildDate
This commit is contained in:
Timothy 2023-10-13 10:51:34 +08:00 committed by GitHub
commit 09c65bdff3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ import { escape } from 'pliny/utils/htmlEscaper.js'
import siteMetadata from '../data/siteMetadata.js'
import tagData from '../app/tag-data.json' assert { type: 'json' }
import { allBlogs } from '../.contentlayer/generated/index.mjs'
import { sortPosts } from 'pliny/utils/contentlayer.js'
const generateRssItem = (config, post) => `
<item>
@ -38,7 +39,7 @@ async function generateRSS(config, allBlogs, page = 'feed.xml') {
const publishPosts = allBlogs.filter((post) => post.draft !== true)
// RSS for blog post
if (publishPosts.length > 0) {
const rss = generateRss(config, publishPosts)
const rss = generateRss(config, sortPosts(publishPosts))
writeFileSync(`./public/${page}`, rss)
}