-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-node.js
64 lines (57 loc) · 1.31 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
const {
createRemoteFileNode,
} = require('gatsby-source-filesystem')
exports.onPreInit = () => {
console.log('Generating image nodes from featured image')
}
exports.pluginOptionsSchema = ({ Joi }) => {
return Joi.object({
image: Joi.string()
.default('featuredImage')
.required()
.description(`Define what will be the featured image key inside the frontmatter.`),
})
}
exports.createResolvers = ({
actions,
cache,
createNodeId,
createResolvers,
store,
reporter,
}, pluginOptions) => {
const { createNode } = actions
const { image } = pluginOptions
createResolvers({
Mdx: {
[image]: {
type: `File`,
resolve(source, args, context, info) {
return createRemoteFileNode({
url: source.frontmatter[image],
parentNodeId: source.id,
cache,
createNode,
createNodeId,
reporter,
})
}
},
},
MarkdownRemark: {
[image]: {
type: `File`,
resolve(source, args, context, info) {
return createRemoteFileNode({
url: source.frontmatter[image],
parentNodeId: source.id,
cache,
createNode,
createNodeId,
reporter,
})
}
},
},
})
}