Handle case when author does not exist

According to the Edge type in allMarkdownRemarkData, the author in
frontmatter could be undefined.

related to #24
This commit is contained in:
tricinel
2017-11-28 14:57:20 +01:00
parent 03df4d4ab8
commit 990a13e2af

View File

@@ -76,18 +76,22 @@ const AllBlogPosts = ({data}: Props) => (
</Link>
</h2>
<MetaTitle>{node.fields.date}</MetaTitle>
<div
css={{
color: colors.subtle,
marginTop: -5,
}}>
by{' '}
{toCommaSeparatedList(node.frontmatter.author, author => (
<span key={author.frontmatter.name}>
{author.frontmatter.name}
</span>
))}
</div>
{node.frontmatter.author ? (
<div
css={{
color: colors.subtle,
marginTop: -5,
}}>
by{' '}
{toCommaSeparatedList(node.frontmatter.author, author => (
<span key={author.frontmatter.name}>
{author.frontmatter.name}
</span>
))}
</div>
) : (
<div />
)}
</li>
))}
</ul>