1const path = require('path')
2
3exports.createPages = ({graphql, boundActionCreators}) => {
4 const {createPage} = boundActionCreators
5 return new Promise((resolve, reject) => {
6 const storeTemplate = path.resolve('src/templates/store.js')
7 resolve(
8 graphql(`
9 {
10 allContentfulStore (limit:100) {
11 edges {
12 node {
13 id
14 name
15 slug
16 }
17 }
18 }
19 }
20 `).then((result) => {
21 if (result.errors) {
22 reject(result.errors)
23 }
24 result.data.allContentfulStore.edges.forEach((edge) => {
25 createPage ({
26 path: edge.node.slug,
27 component: storeTemplate,
28 context: {
29 slug: edge.node.slug
30 }
31 })
32 })
33 return
34 })
35 )
36 })
37}
38