-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-node.js
71 lines (67 loc) · 1.53 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
60
61
62
63
64
65
66
67
68
69
70
71
const path = require(`path`);
exports.onCreateWebpackConfig = ({ actions, stage, loaders }) => {
const config = {
resolve: {
modules: [path.resolve(__dirname, "src"), "node_modules"],
},
};
// when building HTML, window is not defined, so Leaflet causes the build to blow up
if (stage === "build-html") {
config.module = {
rules: [
{
test: /mapbox-gl/,
use: loaders.null(),
},
],
};
}
actions.setWebpackConfig(config);
};
exports.createPages = async ({ graphql, actions }) => {
const { createPage } = actions;
const queryResults = await graphql(`
query {
agences: allAgencesJson {
edges {
node {
id
name
street
street2
zipcode
city
url
phone
thumbnail
organisation {
label
users {
email
firstname
mobile
name
phone
position
url
}
}
}
}
}
}
`);
const detailTemplate = path.resolve(`src/templates/detail.template.js`);
queryResults.data.agences.edges
.map((el) => el.node)
.forEach((node) => {
createPage({
path: `/${node.id}`,
component: detailTemplate,
context: {
// This time the agency product is passed down as context
agence: node,
},
});
});
};