Skip to content

Instantly share code, notes, and snippets.

@adiusz
Created June 24, 2020 10:43
Show Gist options
  • Save adiusz/e953acb277aa0be2e55b0f2787911509 to your computer and use it in GitHub Desktop.
Save adiusz/e953acb277aa0be2e55b0f2787911509 to your computer and use it in GitHub Desktop.
gatby-node
const path = require(`path`)
const { createFilePath } = require(`gatsby-source-filesystem`)
exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions
return new Promise((resolve, reject) => {
graphql(`
{
allDatoCmsProduct {
edges {
node {
slug
}
}
}
}
`).then(result => {
result.data.allDatoCmsProduct.edges.map(({ node: product }) => {
createPage({
path: `produkt/${product.slug}`,
component: path.resolve(`./src/layouts/product.js`),
context: {
slug: product.slug,
},
})
})
resolve()
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment