Repository navigation
Expand file tree
/
Copy pathgatsby-node.js
More file actions
100 lines (99 loc) · 2.29 KB
/
Copy pathgatsby-node.js
File metadata and controls
100 lines (99 loc) · 2.29 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const path = require(`path`)
exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions
return graphql(`
{
pages: allContentfulPage(filter: { layout: { ne: "home" } }) {
edges {
node {
permalink
contentful_id
}
}
}
locations: allContentfulLocation {
edges {
node {
contentful_id
permalink
title
address {
address
}
phone
hours {
days
hours
}
order_online_url
order_pickup_url
menu_pdf {
file {
url
}
}
social_links {
icon
url
}
lat
lng
}
}
}
settings: allContentfulSetting {
edges {
node {
key
value {
value
}
}
}
}
navMenus: allContentfulNavMenu {
edges {
node {
title
links {
title
url
contentfulchildren {
title
url
}
}
}
}
}
}
`).then(result => {
// Create Pages
result.data.pages.edges.forEach(({ node }) => {
createPage({
path: node.permalink,
component: path.resolve(`./src/templates/page.js`),
context: {
permalink: node.permalink,
id: node.contentful_id,
locations: result.data.locations.edges.map(e => e.node),
navMenus: result.data.navMenus.edges.map(e => e.node),
settings: result.data.settings.edges.map(e => e.node),
},
})
})
// Create Locations
result.data.locations.edges.forEach(({ node }) => {
createPage({
path: `/locations/${node.permalink}`,
component: path.resolve(`./src/templates/location.js`),
context: {
permalink: node.permalink,
id: node.contentful_id,
navMenus: result.data.navMenus.edges.map(e => e.node),
settings: result.data.settings.edges.map(e => e.node),
},
})
})
})
}