upstream #1
@ -7,6 +7,8 @@ import tagData from '../app/tag-data.json' assert { type: 'json' }
|
|||||||
import { allBlogs } from '../.contentlayer/generated/index.mjs'
|
import { allBlogs } from '../.contentlayer/generated/index.mjs'
|
||||||
import { sortPosts } from 'pliny/utils/contentlayer.js'
|
import { sortPosts } from 'pliny/utils/contentlayer.js'
|
||||||
|
|
||||||
|
const outputFolder = process.env.EXPORT ? 'out' : 'public'
|
||||||
|
|
||||||
const generateRssItem = (config, post) => `
|
const generateRssItem = (config, post) => `
|
||||||
<item>
|
<item>
|
||||||
<guid>${config.siteUrl}/blog/${post.slug}</guid>
|
<guid>${config.siteUrl}/blog/${post.slug}</guid>
|
||||||
@ -40,7 +42,7 @@ async function generateRSS(config, allBlogs, page = 'feed.xml') {
|
|||||||
// RSS for blog post
|
// RSS for blog post
|
||||||
if (publishPosts.length > 0) {
|
if (publishPosts.length > 0) {
|
||||||
const rss = generateRss(config, sortPosts(publishPosts))
|
const rss = generateRss(config, sortPosts(publishPosts))
|
||||||
writeFileSync(`./public/${page}`, rss)
|
writeFileSync(`./${outputFolder}/${page}`, rss)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (publishPosts.length > 0) {
|
if (publishPosts.length > 0) {
|
||||||
@ -49,7 +51,7 @@ async function generateRSS(config, allBlogs, page = 'feed.xml') {
|
|||||||
post.tags.map((t) => slug(t)).includes(tag)
|
post.tags.map((t) => slug(t)).includes(tag)
|
||||||
)
|
)
|
||||||
const rss = generateRss(config, filteredPosts, `tags/${tag}/${page}`)
|
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 })
|
mkdirSync(rssPath, { recursive: true })
|
||||||
writeFileSync(path.join(rssPath, page), rss)
|
writeFileSync(path.join(rssPath, page), rss)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user