Skip to content

Commit

Permalink
Merge pull request #1039 from timlrx/fix-static-feed
Browse files Browse the repository at this point in the history
fix: static build should write to out folder
  • Loading branch information
timlrx authored Oct 17, 2024
2 parents a9d3d4a + e729f64 commit 4d212bd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/rss.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
}
Expand Down

0 comments on commit 4d212bd

Please sign in to comment.