feat: support multi-author blog post

This commit is contained in:
Timothy Lin
2021-05-18 23:46:30 +08:00
parent 41850ef6f0
commit ed290bfcdd
4 changed files with 30 additions and 22 deletions

View File

@ -24,8 +24,12 @@ export async function getStaticProps({ params }) {
const prev = allPosts[postIndex + 1] || null
const next = allPosts[postIndex - 1] || null
const post = await getFileBySlug('blog', params.slug)
const postAuthor = post.frontMatter.author || 'default'
const { frontMatter: authorDetails } = await getFileBySlug('authors', [postAuthor])
const authorList = post.frontMatter.authors || ['default']
const authorPromise = authorList.map(async (author) => {
const authorResults = await getFileBySlug('authors', [author])
return authorResults.frontMatter
})
const authorDetails = await Promise.all(authorPromise)
// rss
const rss = generateRss(allPosts)