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(
|
|
|
|
|
`
|
|
|
|
|
{
|
2018-06-27 10:35:17 +02:00
|
|
|
allWordpressPost {
|
2018-06-25 09:19:20 +02:00
|
|
|
edges {
|
|
|
|
|
node {
|
|
|
|
|
slug
|
2018-06-27 12:06:15 +02:00
|
|
|
status
|
2018-06-25 09:19:20 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`
|
2018-06-25 10:53:58 +02:00
|
|
|
).then(result => {
|
|
|
|
|
if (result.errors) {
|
|
|
|
|
console.log(result.errors)
|
|
|
|
|
reject(result.errors)
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-27 10:35:17 +02:00
|
|
|
result.data.allWordpressPost.edges.forEach(({ node }) => {
|
2018-06-25 10:53:58 +02:00
|
|
|
createPage({
|
2018-06-27 10:35:17 +02:00
|
|
|
path: `blog/${node.slug}`,
|
2018-06-27 14:20:54 +02:00
|
|
|
component: path.resolve('./src/templates/post-default.js'),
|
2018-06-25 15:28:50 +02:00
|
|
|
context: {
|
|
|
|
|
slug: node.slug,
|
|
|
|
|
}
|
2018-06-25 10:53:58 +02:00
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
resolve()
|
|
|
|
|
})
|
2018-06-25 09:19:20 +02:00
|
|
|
})
|
|
|
|
|
}
|