fix: do not generate rss if no valid posts

This commit is contained in:
Timothy Lin committed 2021-12-15 17:09:53 +08:00
1 parent e48573e2bf
commit 4e563ed151
2 files changed
+10 -6

No files matched your search

+4 -2
View File
@@ -32,8 +32,10 @@ export async function getStaticProps({ params }) {
const authorDetails = await Promise.all(authorPromise)
// rss
const rss = generateRss(allPosts)
fs.writeFileSync('./public/feed.xml', rss)
if (allPosts.length > 0) {
const rss = generateRss(allPosts)
fs.writeFileSync('./public/feed.xml', rss)
}
return { props: { post, authorDetails, prev, next } }
}