mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-02-23 01:54:18 -08:00
39 lines
No EOL
943 B
JavaScript
39 lines
No EOL
943 B
JavaScript
exports.createPages = async ({ actions, graphql, reporter }) => {
|
|
const { createPage } = actions
|
|
|
|
const blogPostTemplate = require.resolve(`./src/templates/postTemplate.js`)
|
|
|
|
const result = await graphql(`
|
|
{
|
|
allMarkdownRemark(
|
|
sort: { order: DESC, fields: [frontmatter___date] }
|
|
limit: 1000
|
|
) {
|
|
edges {
|
|
node {
|
|
frontmatter {
|
|
slug
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`)
|
|
|
|
// Handle errors
|
|
if (result.errors) {
|
|
reporter.panicOnBuild(`Error while running GraphQL query.`)
|
|
return
|
|
}
|
|
|
|
result.data.allMarkdownRemark.edges.forEach(({ node }) => {
|
|
createPage({
|
|
path: node.frontmatter.slug,
|
|
component: blogPostTemplate,
|
|
context: {
|
|
// additional data can be passed via context
|
|
slug: node.frontmatter.slug,
|
|
},
|
|
})
|
|
})
|
|
} |