Skip to content

Instantly share code, notes, and snippets.

module.exports = {
siteMetadata: {
siteName: 'My Shop',
},
plugins: [
// ...
{
resolve: 'gatsby-plugin-snipcart',
options: {
apiKey: 'YOUR-SNIPCART-API-TOKEN',
import React from 'react'
import Img from 'gatsby-image'
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">
<div className="Product__image">
<img src={`${product.image.url}?w=300&h=300&fit=crop&fm=jpg`} />
</div>
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} />
module.exports = {
siteMetadata: {
siteName: 'My Shop',
},
plugins: [
'gatsby-plugin-sass',
'gatsby-plugin-react-helmet',
{
resolve: `gatsby-source-datocms`,
options: { apiToken: `YOUR_READONLY_API_TOKEN` },
const { SiteClient } = require('datocms-client');
const client = new SiteClient('YOUR-API-TOKEN');
const config = require('./gatsby-config');
config.siteMetadata.products.reduce((chain, product) => (
chain
.then(() => client.uploadImage(product.image))
.then((image) => client.items.create({
name: product.name,
image: image,
module.exports = {
siteMetadata: {
siteName: 'My Shop',
products: [
{
name: 'Bloom',
image: 'https://www.pacificandco.com/wp-content/uploads/2014/12/pacificandco-calcetines-socks-original-creative-women-BLOOM-perfil-1.jpg',
price: 14.95,
},
{
import React from 'react'
const IndexPage = ({ data }) => (
<div className="Catalogue">
{
data.site.siteMetadata.products.map(product => (
<div className="Catalogue__item" key={product.slug}>
<a href="#" className="Product">
<div className="Product__image">
<img src={product.image} />
for ((i=1;i<=100;i++)); do curl 'https://datocms-gql.global.ssl.fastly.net/' -H 'Authorization: faeb9172e232a75339242faafb9e56de8c8f13b735f7090964' -H 'Content-Type: application/json' -H 'Accept:
application/json' --data-binary '{ "query": "{ faq { question } }" }' -D - -s | grep -e X-Cache -e X-Served-By; done
X-Served-By: cache-lcy19247-LCY, cache-fra19145-FRA
X-Cache: MISS, HIT
X-Cache-Hits: 0, 1
X-Served-By: cache-lcy19226-LCY, cache-fra19133-FRA
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0
X-Served-By: cache-lcy19228-LCY, cache-fra19137-FRA
sub vcl_hash {
#FASTLY hash
set req.hash += req.url;
set req.hash += req.http.host;
set req.hash += req.http.Authorization;
if (req.request == "POST" && req.postbody) {
set req.hash += req.postbody;
}