1 | "use strict";
|
2 |
|
3 | const {
|
4 | supportedExtensions
|
5 | } = require(`./supported-extensions`);
|
6 |
|
7 | module.exports = async function onCreateNode({
|
8 | node,
|
9 | actions,
|
10 | createNodeId
|
11 | }) {
|
12 | const {
|
13 | createNode,
|
14 | createParentChildLink
|
15 | } = actions;
|
16 |
|
17 | if (!supportedExtensions[node.extension]) {
|
18 | return;
|
19 | }
|
20 |
|
21 | const imageNode = {
|
22 | id: createNodeId(`${node.id} >> ImageSharp`),
|
23 | children: [],
|
24 | parent: node.id,
|
25 | internal: {
|
26 | contentDigest: `${node.internal.contentDigest}`,
|
27 | type: `ImageSharp`
|
28 | }
|
29 | };
|
30 | createNode(imageNode);
|
31 | createParentChildLink({
|
32 | parent: node,
|
33 | child: imageNode
|
34 | });
|
35 | return;
|
36 | }; |
\ | No newline at end of file |