diff --git a/scripts/rss.mjs b/scripts/rss.mjs index b7e33fb34..f493257e0 100644 --- a/scripts/rss.mjs +++ b/scripts/rss.mjs @@ -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) => ` ${config.siteUrl}/blog/${post.slug} @@ -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) }