37 lines
750 B
JavaScript
37 lines
750 B
JavaScript
const path = require('path')
|
|
|
|
exports.createPages = ({ graphql, boundActionCreators }) => {
|
|
const { createPage } = boundActionCreators
|
|
return new Promise((resolve, reject) => {
|
|
graphql(
|
|
`
|
|
{
|
|
allWordpressPage {
|
|
edges {
|
|
node {
|
|
id
|
|
slug
|
|
title
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`
|
|
).then(result => {
|
|
if (result.errors) {
|
|
console.log(result.errors)
|
|
reject(result.errors)
|
|
}
|
|
|
|
result.data.allWordpressPage.edges.forEach(({ node }) => {
|
|
createPage({
|
|
path: node.slug,
|
|
component: path.resolve('./src/pages/page.js'),
|
|
})
|
|
})
|
|
|
|
resolve()
|
|
})
|
|
})
|
|
}
|