This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://nec.is/writing/transform-your-codebase-using-codemods/ | |
export default function transformer(file, api) { | |
const j = api.jscodeshift; | |
const root = j(file.source); | |
root.find( | |
j.ExportDefaultDeclaration, | |
{ | |
declaration: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/setup" | |
require "commercelayer" | |
client = Commercelayer::Client.new( | |
site: "https://dato-commerce.commercelayer.io", | |
client_id: "18b638d6d9849ab88f10e3cd95c43c4b54b4d03988660c8424e8427a93dc9cd6", | |
client_secret: "5977be2042d6cac22e8340961bdf84263c37444a002e6a9b180d5b7b70ac6a1f" | |
) | |
client.authorize! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var talks = []; | |
var currentIndex = 0; | |
function formatDate(template, date) { | |
var specs = 'YYYY:MM:DD:HH:mm:ss'.split(':'); | |
date = new Date(date || Date.now() - new Date().getTimezoneOffset() * 6e4); | |
return date.toISOString().split(/[-:.TZ]/).reduce(function(template, item, i) { | |
return template.split(specs[i]).join(item); | |
}, template); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Ciao!'); | |
simply.on('singleClick', function(e) { | |
console.log(util2.format('single clicked $button!', e)); | |
simply.subtitle('Pressed ' + e.button + '!'); | |
}); | |
simply.on('longClick', function(e) { | |
console.log(util2.format('long clicked $button!', e)); | |
simply.vibe(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const IndexPage = ({ data }) => ( | |
<div className="Catalogue"> | |
{ | |
data.products.edges.map(({ node: product }) => ( | |
<div className="Catalogue__item" key={product.id}> | |
<a | |
href="#" | |
className="Product snipcart-add-item" | |
data-item-id={product.slug} | |
data-item-price={product.price} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="#" className="Header__summary snipcart-summary snipcart-checkout"> | |
<div className="Header__summary__title"> | |
🛍 MY CART 🛍 | |
</div> | |
<div className="Header__summary__line"> | |
Number of items: <span className="snipcart-total-items"></span> | |
</div> | |
<div className="Header__summary__line"> | |
Total price: <span className="snipcart-total-price"></span> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
siteMetadata: { | |
siteName: 'My Shop', | |
}, | |
plugins: [ | |
// ... | |
{ | |
resolve: 'gatsby-plugin-snipcart', | |
options: { | |
apiKey: 'YOUR-SNIPCART-API-TOKEN', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div className="Product__image"> | |
<img src={`${product.image.url}?w=300&h=300&fit=crop&fm=jpg`} /> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} /> |