39 lines
803 B
JavaScript
39 lines
803 B
JavaScript
|
const path = require(`path`)
|
||
|
|
||
|
exports.createPages = async ({ actions, graphql, reporter }) => {
|
||
|
const { createPage } = actions
|
||
|
|
||
|
const blogPostTemplate = path.resolve(`src/templates/simpleTemplate.js`)
|
||
|
|
||
|
const result = await graphql(`
|
||
|
{
|
||
|
allMarkdownRemark(
|
||
|
limit: 1000
|
||
|
) {
|
||
|
edges {
|
||
|
node {
|
||
|
frontmatter {
|
||
|
path
|
||
|
title
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
`)
|
||
|
|
||
|
// Handle errors
|
||
|
if (result.errors) {
|
||
|
reporter.panicOnBuild(`Error while running GraphQL query.`)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result.data.allMarkdownRemark.edges.forEach(({ node }) => {
|
||
|
createPage({
|
||
|
path: node.frontmatter.path,
|
||
|
component: blogPostTemplate,
|
||
|
context: {}, // additional data can be passed via context
|
||
|
})
|
||
|
})
|
||
|
}
|