Merge pull request #293 from timlrx/fix/draft-post
fix: do not generate rss if no valid posts
This commit is contained in:
		| @@ -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 } } | ||||
| } | ||||
|   | ||||
| @@ -30,10 +30,12 @@ export async function getStaticProps({ params }) { | ||||
|   ) | ||||
|  | ||||
|   // rss | ||||
|   const rss = generateRss(filteredPosts, `tags/${params.tag}/feed.xml`) | ||||
|   const rssPath = path.join(root, 'public', 'tags', params.tag) | ||||
|   fs.mkdirSync(rssPath, { recursive: true }) | ||||
|   fs.writeFileSync(path.join(rssPath, 'feed.xml'), rss) | ||||
|   if (filteredPosts.length > 0) { | ||||
|     const rss = generateRss(filteredPosts, `tags/${params.tag}/feed.xml`) | ||||
|     const rssPath = path.join(root, 'public', 'tags', params.tag) | ||||
|     fs.mkdirSync(rssPath, { recursive: true }) | ||||
|     fs.writeFileSync(path.join(rssPath, 'feed.xml'), rss) | ||||
|   } | ||||
|  | ||||
|   return { props: { posts: filteredPosts, tag: params.tag } } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user