Skip to content

Instantly share code, notes, and snippets.

@stefanoverna
Created June 7, 2018 15: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 stefanoverna/5b0d53f13681e34b78229cf29f0c6de7 to your computer and use it in GitHub Desktop.
Save stefanoverna/5b0d53f13681e34b78229cf29f0c6de7 to your computer and use it in GitHub Desktop.
import React from 'react'
const IndexPage = ({ data }) => (
<div className="Catalogue">
{
data.products.edges.map(({ node: product }) => (
<div className="Catalogue__item" key={product.id}>
<a href="#" className="Product">
<div className="Product__image">
<img src={product.image.url} />
</div>
<div className="Product__details">
<div className="Product__name">
{product.name}
<div className="Product__price">
{product.price}€
</div>
</div>
<span className="Product__buy">Buy now</span>
</div>
</a>
</div>
))
}
</div>
)
export default IndexPage
export const query = graphql`
query CatalogueQuery {
products: allDatoCmsProduct {
edges {
node {
id
name
price
image {
url
}
}
}
}
}
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment