Skip to content

Instantly share code, notes, and snippets.

@nickpunt
Created June 2, 2018 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickpunt/013396734240d4467ae9cf440a8414a8 to your computer and use it in GitHub Desktop.
Save nickpunt/013396734240d4467ae9cf440a8414a8 to your computer and use it in GitHub Desktop.
fix for gatsbyjs airtable blog
<Box>
{posts
.filter(post => post.node.title.length > 0)
.map(({ node: post }, index) => {
return (
<Box key={post.id}>
<Link to={post.slug} className={linkStyles}>
<Timestamp>{post.date}</Timestamp>
<h3>{post.title}</h3>
<div
style={{
backgroundImage: 'url(' + post.image[0].url + ')',
backgroundSize: '100%',
backgroundPosition: 'center',
width:'100%',
height:'15rem'
}}>
</div>
<p
style={{
marginTop: '1rem',
marginBottom: '2rem',
}}>
<div
dangerouslySetInnerHTML={{
__html: String(unified()
.use(markdown)
.use(html)
.processSync(post.PostMarkdown.split(/\s+/).slice(0,35).join(" ")))
}} />
</p>
</Link>
</Box>
);
})}
</Box>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment