homepage/gatsby-node.js

39 lines
771 B
JavaScript
Raw Normal View History

2019-12-12 21:27:56 +00:00
const path = require(`path`)
exports.createPages = async ({ actions, graphql, reporter }) => {
const { createPage } = actions
2019-12-13 14:51:59 +00:00
const siteTemplate = path.resolve(`src/templates/siteTemplate.js`)
2019-12-12 21:27:56 +00:00
const result = await graphql(`
{
2019-12-12 23:03:04 +00:00
allMdx(
2019-12-12 21:27:56 +00:00
limit: 1000
) {
edges {
node {
frontmatter {
path
title
}
}
}
}
}
`)
// Handle errors
if (result.errors) {
reporter.panicOnBuild(`Error while running GraphQL query.`)
return
}
2019-12-12 23:03:04 +00:00
result.data.allMdx.edges.forEach(({ node }) => {
2019-12-12 21:27:56 +00:00
createPage({
path: node.frontmatter.path,
2019-12-13 14:51:59 +00:00
component: siteTemplate,
2019-12-12 21:27:56 +00:00
context: {}, // additional data can be passed via context
})
})
}