Closed amit-deligence closed 6 years ago
I’d say something like this?
const productSet = new Set();
const categorySet = new Set();
const productList = Array.from(productSet);
productList.forEach((product) => {
createPage({
path: `/product/${_.kebabCase(product)}/`,
component: productPage,
context: {
product,
},
});
});
const categoryList = Array.from(categorySet);
categoryList.forEach((category) => {
createPage({
path: `/categories/${_.kebabCase(category)}/`,
component: categoryPage,
context: {
category,
},
});
});
I'm on my mobile phone right now so it's not that easy to write code but I hope you get the idea. That's how I do it to
Working example here @amit-deligence using datocms as a source https://github.com/shansmith01/mad/blob/master/gatsby-node.js
Thanks @shansmith01 it worked.
@Manoz thanks for your advice
Summary
Relevant information
Environment (if relevant)
File contents (if changed)
gatsby-config.js
: N/Apackage.json
: N/Agatsby-node.js
: N/Agatsby-browser.js
: N/Agatsby-ssr.js
: N/A