-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-node.js
45 lines (39 loc) · 861 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
43
44
45
const path = require('path')
exports.createPages = async ({ graphql, actions }) => {
const { createPage } = actions
// Query all Pages with their IDs and template data.
const pages = await graphql(`
{
allPrismicPage {
edges {
node {
id
uid
}
}
}
}
`)
const pageList = pages.data.allPrismicPage.edges
const pageTemplate = require.resolve("./src/templates/Page.js")
pageList.forEach(edge => {
const url = `/${edge.node.uid}`
if (url === '/home') {
createPage({
path: '/',
component: pageTemplate,
context: {
uid: edge.node.uid,
},
})
} else {
createPage({
path: url,
component: pageTemplate,
context: {
uid: edge.node.uid,
},
})
}
})
}