-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-node.js
38 lines (33 loc) · 1.01 KB
/
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
const path = require("path")
const { isSourceableMdxFile, MDX_SOURCES } = require("./src/common/sources")
const createMdxFields = require("./src/common/create-mdx-fields")
const createMdxPages = require("./src/common/create-mdx-pages")
const createPaginationPages = require("./src/common/create-pagination-pages")
exports.onCreateNode = ({ node, actions, getNode }) => {
if (isSourceableMdxFile(node, getNode)) {
createMdxFields(node, actions, getNode)
}
}
exports.createPages = async ({ graphql, actions, reporter }) => {
for (mdxSource of MDX_SOURCES) {
const source = mdxSource.name
await createMdxPages(
source,
path.resolve(
path.join(__dirname, "src", "templates", `${source}-post.tsx`)
),
actions,
graphql,
reporter
)
if (mdxSource.paginated) {
await createPaginationPages(
source,
path.resolve(path.join(__dirname, "src", "templates", `${source}.tsx`)),
actions,
graphql,
reporter
)
}
}
}