-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgatsby-node.js
More file actions
35 lines (31 loc) · 922 Bytes
/
gatsby-node.js
File metadata and controls
35 lines (31 loc) · 922 Bytes
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
const crypto = require("crypto");
const data = require("./src/data/data.json");
exports.sourceNodes = ({ actions }) => {
const { createNode } = actions;
data.map((code) => {
const content = {
id: code.id,
char: code.char,
name: code.name,
category: code.category,
htmlEntity: code.htmlEntity,
htmlCode: code.htmlCode,
hexCode: code.hexCode,
cssCode: code.cssCode
};
const nodeContent = JSON.stringify(content);
createNode({
...content,
parent: null,
children: [],
internal: {
type: `code`,
content: nodeContent,
contentDigest: crypto
.createHash("md5")
.update(nodeContent)
.digest("hex")
}
});
});
};