-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgatsby-node.js
59 lines (49 loc) · 1.17 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// gatsby-node.js
// Implement the Gatsby API “onCreatePage”.
// This is called after every page is created.
const speakerProfilePage = {
match: /^\/speakers\/profile/,
matchPath: '/speakers/profile/*'
}
const aboutPage = {
match: /^\/about/,
matchPath: '/about/*'
}
const schedulePage = {
match: /^\/schedule/,
matchPath: '/schedule/*'
}
const createPageHandler = ({ page, matchPath, createPage }) => {
page.matchPath = matchPath
// Update the page.
createPage(page)
}
const createDynamicPages = async ({ page, actions }) => {
const { createPage } = actions
// page.matchPath is a special key that's used for matching pages
// only on the client.
if (page.path.match(speakerProfilePage.match)) {
createPageHandler({
createPage,
page,
matchPath: speakerProfilePage.matchPath
})
}
/*
if (page.path.match(aboutPage.match)) {
createPageHandler({
createPage,
page,
matchPath: aboutPage.matchPath
})
}
if (page.path.match(schedulePage.match)) {
createPageHandler({
createPage,
page,
matchPath: schedulePage.matchPath
})
}
*/
}
exports.onCreatePage = createDynamicPages