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> </Link>
</h2> </h2>
<MetaTitle>{node.fields.date}</MetaTitle> <MetaTitle>{node.fields.date}</MetaTitle>
<div {node.frontmatter.author ? (
css={{ <div
color: colors.subtle, css={{
marginTop: -5, color: colors.subtle,
}}> marginTop: -5,
by{' '} }}>
{toCommaSeparatedList(node.frontmatter.author, author => ( by{' '}
<span key={author.frontmatter.name}> {toCommaSeparatedList(node.frontmatter.author, author => (
{author.frontmatter.name} <span key={author.frontmatter.name}>
</span> {author.frontmatter.name}
))} </span>
</div> ))}
</div>
) : (
<div />
)}
</li> </li>
))} ))}
</ul> </ul>

Loading…
Cancel
Save