Skip to content

Commit 990a13e

Browse files
committed
Handle case when author does not exist
According to the Edge type in allMarkdownRemarkData, the author in frontmatter could be undefined. related to reactjs#24
1 parent 03df4d4 commit 990a13e

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

Diff for: src/pages/blog/all.html.js

+16-12
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,22 @@ const AllBlogPosts = ({data}: Props) => (
7676
</Link>
7777
</h2>
7878
<MetaTitle>{node.fields.date}</MetaTitle>
79-
<div
80-
css={{
81-
color: colors.subtle,
82-
marginTop: -5,
83-
}}>
84-
by{' '}
85-
{toCommaSeparatedList(node.frontmatter.author, author => (
86-
<span key={author.frontmatter.name}>
87-
{author.frontmatter.name}
88-
</span>
89-
))}
90-
</div>
79+
{node.frontmatter.author ? (
80+
<div
81+
css={{
82+
color: colors.subtle,
83+
marginTop: -5,
84+
}}>
85+
by{' '}
86+
{toCommaSeparatedList(node.frontmatter.author, author => (
87+
<span key={author.frontmatter.name}>
88+
{author.frontmatter.name}
89+
</span>
90+
))}
91+
</div>
92+
) : (
93+
<div />
94+
)}
9195
</li>
9296
))}
9397
</ul>

0 commit comments

Comments
 (0)