Skip to content

Instantly share code, notes, and snippets.

@sumitkharche
Created June 26, 2019 18:01
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 sumitkharche/6da1c6d08fb9d921f3dadf01db302ef3 to your computer and use it in GitHub Desktop.
Save sumitkharche/6da1c6d08fb9d921f3dadf01db302ef3 to your computer and use it in GitHub Desktop.
index.js
import React from 'react'
import {withRouteData} from 'react-static'
import {Link } from '@reach/router'
export default withRouteData(({posts}) =>(
<React.Fragment>
<div className="container">
{posts.map(post => (
<Link key={post._id} to={`/post/${post._id}`} className="card">
<div style={{ paddingRight: "1em" }}>
<img
alt={post.metadata.title}
className="card-img"
src={post.metadata.image.url}
/>
</div>
<div>
<h3 style={{ margin: 0 }}>{post.metadata.title}</h3>
</div>
</Link>
))}
</div>
</React.Fragment>
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment