Browse Source

Handle case when author does not exist

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

related to #24
main
tricinel 7 years ago
parent
commit
990a13e2af
  1. 28
      src/pages/blog/all.html.js

28
src/pages/blog/all.html.js

@ -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>

Loading…
Cancel
Save