-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgatsby-node.js
More file actions
50 lines (38 loc) · 1.19 KB
/
gatsby-node.js
File metadata and controls
50 lines (38 loc) · 1.19 KB
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
/**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/
exports.onCreatePage = async ({ page, actions }) => {
const { createPage, deletePage } = actions
// page.matchPath is a special key that's used for matching pages
// only on the client.
if (page.path.match(/^\/app/)) {
page.matchPath = `/app/*`
// Update the page.
createPage(page)
}
console.log(`page.path ---> : ${page.path}`)
if (page.path.match(/^\/redkite/)) {
// const oldPage = Object.assign({}, page)
// const replacePath = path => path.replace(/^\/redkite/, ``)
// // Remove trailing slash unless page is /
// console.log(`page.path ---> : ${page.path}`)
// page.path = replacePath(page.path)
// console.log(`replacePath ---> : ${page.path}`)
// if (page.path !== oldPage.path) {
// // Replace new page with old page
// deletePage(oldPage)
// createPage(page)
// }
page.matchPath = `/*`
// page.matchPath = `/redkite/*`
// Update the page.
createPage(page)
}
if (page.path.match(/^\/admin/)) {
page.matchPath = `/admin/*`
// Update the page.
createPage(page)
}
}