-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-node.js
57 lines (50 loc) · 1.14 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
const path = require(`path`);
exports.createPages = async ({ graphql, actions }) => {
const { createPage } = actions
// const { createRedirect } = actions
const homePage = path.resolve(`./src/templates/page.jsx`)
const subPage = path.resolve(`./src/templates/subPage.jsx`)
const queryResult = await graphql(`
query {
allPrismicSubpage {
nodes {
id
url
}
}
}
`)
// const redirections = await graphql(`
// query {
// prismicRedirections {
// data {
// redirections {
// from
// to
// }
// }
// }
// }
// `)
createPage({
path: "/",
component: homePage,
context: {
id: "homePage"
},
});
// const redirects = redirections.data.prismicRedirections.data.redirections
// redirects.forEach(redirect => {
// createRedirect({
// fromPath: redirect.from,
// toPath: redirect.to
// })
// })
for (const page of queryResult.data.allPrismicSubpage.nodes ?? []) {
createPage({
path: page.url,
component: subPage,
context: { id: page.id }
})
}
}