2018-04-07 14:18:06 +02:00
|
|
|
const path = require('path')
|
2018-04-06 17:24:35 +02:00
|
|
|
|
2018-06-19 22:48:33 +02:00
|
|
|
//
|
|
|
|
// Create project pages from projects.yml
|
|
|
|
//
|
2018-06-23 21:53:57 +02:00
|
|
|
exports.createPages = async ({ actions, graphql }) => {
|
2018-06-13 20:46:36 +02:00
|
|
|
const { createPage } = actions
|
2018-04-07 14:18:06 +02:00
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
2018-04-25 23:37:23 +02:00
|
|
|
const template = path.resolve('src/templates/Project.jsx')
|
2018-04-07 14:18:06 +02:00
|
|
|
|
2018-05-12 22:14:53 +02:00
|
|
|
resolve(
|
|
|
|
graphql(`
|
2018-04-07 14:18:06 +02:00
|
|
|
{
|
2018-05-05 00:17:26 +02:00
|
|
|
allProjectsYaml {
|
2018-04-07 14:18:06 +02:00
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
slug
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`).then(result => {
|
|
|
|
if (result.errors) {
|
|
|
|
reject(result.errors)
|
|
|
|
}
|
|
|
|
|
2018-06-19 22:48:33 +02:00
|
|
|
result.data.allProjectsYaml.edges.forEach(({ node }) => {
|
|
|
|
const slug = node.slug
|
2018-04-07 14:18:06 +02:00
|
|
|
|
2018-06-19 22:48:33 +02:00
|
|
|
createPage({
|
|
|
|
path: slug,
|
|
|
|
component: template,
|
|
|
|
context: {
|
|
|
|
slug
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
2018-04-07 14:18:06 +02:00
|
|
|
|
|
|
|
resolve()
|
2018-05-12 22:14:53 +02:00
|
|
|
})
|
|
|
|
)
|
2018-04-07 14:18:06 +02:00
|
|
|
})
|
|
|
|
}
|