forked from lachouettecoop/participation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-node.js
33 lines (32 loc) · 803 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
/**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/
const path = require("path");
exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions;
return new Promise((resolve, reject) => {
graphql(`
{
allChouettos(filter: { barcode: { ne: null } }) {
edges {
node {
barcode
mail
}
}
}
}
`).then(result => {
result.data.allChouettos.edges.forEach(({ node }) => {
createPage({
path: `chouettos/${node.barcode}`,
component: path.resolve(`./src/templates/chouettos.js`),
context: { barcode: node.barcode, mail: node.mail }
});
});
resolve();
});
});
};