forked from benjaminion/upgrading-ethereum-book
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gatsby-node.js
42 lines (37 loc) · 1006 Bytes
/
gatsby-node.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const path = require('path')
const prebuild = require('./bin/build/prebuild')
// Set up a hook to pre-process the source file into split files, and perform various
// checking and linting operations prior to building.
exports.onPreInit = ({ reporter }) => {
try {
prebuild.runChecks(reporter, false)
} catch (err) {
reporter.panicOnBuild('Could not run pre-build tasks,', err)
}
}
exports.createPages = async ({ actions, graphql }) => {
const { createPage } = actions
const pageTemplate = path.resolve(`src/templates/pageTemplate.js`)
const result = await graphql(`
{
allMarkdownRemark {
edges {
node {
frontmatter {
path
}
}
}
}
}
`)
if (result.errors) {
reporter.panicOnBuild(`Error while running GraphQL query.`)
}
result.data.allMarkdownRemark.edges.forEach(({ node }) => {
createPage({
path: node.frontmatter.path,
component: pageTemplate,
})
})
}