2018-06-25 09:19:20 +02:00
|
|
|
const path = require('path')
|
|
|
|
|
|
|
|
|
|
exports.createPages = ({ graphql, boundActionCreators }) => {
|
|
|
|
|
const { createPage } = boundActionCreators
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
graphql(
|
|
|
|
|
`
|
|
|
|
|
{
|
|
|
|
|
allWordpressPage {
|
|
|
|
|
edges {
|
|
|
|
|
node {
|
|
|
|
|
id
|
|
|
|
|
slug
|
|
|
|
|
title
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`
|
2018-06-25 10:53:58 +02:00
|
|
|
).then(result => {
|
|
|
|
|
if (result.errors) {
|
|
|
|
|
console.log(result.errors)
|
|
|
|
|
reject(result.errors)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.data.allWordpressPage.edges.forEach(({ node }) => {
|
|
|
|
|
createPage({
|
|
|
|
|
path: node.slug,
|
2018-06-25 15:28:50 +02:00
|
|
|
component: path.resolve('./src/pages/page-default.js'),
|
|
|
|
|
context: {
|
|
|
|
|
slug: node.slug,
|
|
|
|
|
}
|
2018-06-25 10:53:58 +02:00
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
resolve()
|
|
|
|
|
})
|
2018-06-25 09:19:20 +02:00
|
|
|
})
|
|
|
|
|
}
|