Created
June 24, 2020 10:43
-
-
Save adiusz/e953acb277aa0be2e55b0f2787911509 to your computer and use it in GitHub Desktop.
gatby-node
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 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