-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgatsby-node.js
More file actions
45 lines (40 loc) · 1.11 KB
/
gatsby-node.js
File metadata and controls
45 lines (40 loc) · 1.11 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
/**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/
var {requestImage} = require("./tasks/node-helpers");
// Import all the WCM photos you'd like to use in this project
// NOTE: Leave this as an empty array if you aren't importing any WCM photos, but you won't be able to use the WCMImage component
const wcmPhotos = [20374215]
// Create nodes so GraphQL can access
exports.sourceNodes = async ({
actions,
createNodeId,
createContentDigest,
}) => {
const { createNode } = actions
// Request and push photo data into an array
const photoData = [];
wcmPhotos.forEach((url) => {
photoData.push(requestImage(url))
})
// Take the ratios/ids turn them into graphql nodes
await Promise.all(photoData).then((values) => {
values.forEach((photo) => {
const type = "wcmPhotos";
createNode({
photo,
id: createNodeId(`${type}${photo.wcmid}`),
parent: null,
children: [],
internal: {
contentDigest: createContentDigest(photo),
type,
},
})
})
return
})
return
}