forked from kamleshchandnani/awesome-interview-processes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-node.js
36 lines (35 loc) · 883 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
34
35
36
exports.createSchemaCustomization = ({ actions, schema }) => {
const { createTypes } = actions;
const typeDefs = `
type BlogPost implements Node @nodeInterface {
date: Date @dateformat
}
type MdxBlogPost implements Node @infer {
fields: MdxBlogPostFields
}
type MdxBlogPostFields @infer {
index: Int
}
`;
createTypes(typeDefs);
createTypes(
schema.buildObjectType({
name: `MdxBlogPost`,
fields: {
date: { type: `Date`, extensions: { dateformat: {} } }
},
interfaces: [`Node`, `BlogPost`]
})
);
};
exports.onCreateNode = ({ node, actions, getNode }) => {
const { createNodeField } = actions;
if (node.internal.type === `MdxBlogPost`) {
const parent = getNode(node.parent);
createNodeField({
node,
name: "index",
value: parent.frontmatter.index
});
}
};