Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Commit

Permalink
Prevent errors on posts without cover image
Browse files Browse the repository at this point in the history
  • Loading branch information
justsml committed Sep 30, 2018
1 parent c679c38 commit beab7f5
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/components/Navigator/ListItem.js
Expand Up @@ -149,19 +149,22 @@ class ListItem extends React.Component {
to={post.node.fields.slug}
onClick={linkOnClick}
>
<div className={`${classes.listItemPointer} pointer`}>
<LazyLoad height={60} overflow={true} throttle={300} once={true} offset={100}>
<picture>
<source
type="image/webp"
srcSet={post.node.frontmatter.cover.children[0].resolutions.srcSetWebp}
/>
<source srcSet={post.node.frontmatter.cover.children[0].resolutions.srcSet} />
<img src={post.node.frontmatter.cover.children[0].resolutions.src} alt="" />
</picture>
</LazyLoad>
{/*<Img sizes={post.node.frontmatter.cover.children[0].sizes} />*/}
</div>
{post.node.frontmatter.cover &&
post.node.frontmatter.cover.children[0] && (
<div className={`${classes.listItemPointer} pointer`}>
<LazyLoad height={60} overflow={true} throttle={300} once={true} offset={100}>
<picture>
<source
type="image/webp"
srcSet={post.node.frontmatter.cover.children[0].resolutions.srcSetWebp}
/>
<source srcSet={post.node.frontmatter.cover.children[0].resolutions.srcSet} />
<img src={post.node.frontmatter.cover.children[0].resolutions.src} alt="" />
</picture>
</LazyLoad>
</div>
)}

<div className={classes.listItemText}>
<h1>{post.node.frontmatter.title}</h1>
{post.node.frontmatter.subTitle && <h2>{post.node.frontmatter.subTitle}</h2>}
Expand Down

0 comments on commit beab7f5

Please sign in to comment.