1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-23 01:29:41 +01:00
portfolio/gatsby-node.js
2018-08-16 00:14:40 +02:00

45 lines
856 B
JavaScript

const path = require('path')
//
// Create project pages from projects.yml
//
exports.createPages = async ({ actions, graphql }) => {
const { createPage } = actions
return new Promise((resolve, reject) => {
const template = path.resolve('src/templates/Project.jsx')
resolve(
graphql(`
{
allProjectsYaml {
edges {
node {
slug
}
}
}
}
`).then(result => {
if (result.errors) {
reject(result.errors)
}
result.data.allProjectsYaml.edges.forEach(({ node }) => {
const slug = node.slug
createPage({
path: slug,
component: template,
context: {
slug
}
})
})
resolve()
})
)
})
}