Merge pull request #1039 from timlrx/fix-static-feed

fix: static build should write to out folder
This commit is contained in:
Timothy 2024-10-17 22:23:16 +08:00 committed by GitHub
commit 4d212bd4e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,6 +7,8 @@ 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 outputFolder = process.env.EXPORT ? 'out' : 'public'
const generateRssItem = (config, post) => `
<item>
<guid>${config.siteUrl}/blog/${post.slug}</guid>
@ -40,7 +42,7 @@ async function generateRSS(config, allBlogs, page = 'feed.xml') {
// RSS for blog post
if (publishPosts.length > 0) {
const rss = generateRss(config, sortPosts(publishPosts))
writeFileSync(`./public/${page}`, rss)
writeFileSync(`./${outputFolder}/${page}`, rss)
}
if (publishPosts.length > 0) {
@ -49,7 +51,7 @@ async function generateRSS(config, allBlogs, page = 'feed.xml') {
post.tags.map((t) => slug(t)).includes(tag)
)
const rss = generateRss(config, filteredPosts, `tags/${tag}/${page}`)
const rssPath = path.join('public', 'tags', tag)
const rssPath = path.join(outputFolder, 'tags', tag)
mkdirSync(rssPath, { recursive: true })
writeFileSync(path.join(rssPath, page), rss)
}