Skip to content

Commit

Permalink
chore(gatsby-plugin-mdx): Don't inline typedefs (#16229)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst authored and sidharthachatterjee committed Jul 30, 2019
1 parent df3f88a commit 15ae936
Showing 1 changed file with 24 additions and 36 deletions.
60 changes: 24 additions & 36 deletions packages/gatsby-plugin-mdx/gatsby/source-nodes.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
const {
GraphQLObjectType,
GraphQLInt,
GraphQLJSON
} = require("gatsby/graphql");
const _ = require("lodash");
const remark = require("remark");
const english = require("retext-english");
Expand Down Expand Up @@ -66,24 +61,30 @@ module.exports = (
const options = defaultOptions(pluginOptions);

createTypes(`
type MdxFrontmatter {
title: String!
type MdxFrontmatter {
title: String!
}
}
type MdxHeadingMdx {
value: String
depth: Int
}
type MdxHeadingMdx {
value: String
depth: Int
}
enum HeadingsMdx {
h1,
h2,
h3,
h4,
h5,
h6
}
`);
enum HeadingsMdx {
h1,
h2,
h3,
h4,
h5,
h6
}
type MdxWordCount {
paragraphs: Int
sentences: Int
words: Int
}
`);

/**
* Support gatsby-remark parser plugins
Expand Down Expand Up @@ -201,7 +202,7 @@ ${e}`
}
},
mdxAST: {
type: GraphQLJSON,
type: `JSON`,
async resolve(mdxNode) {
const { mdast } = await processMDX({ node: mdxNode });
return mdast;
Expand Down Expand Up @@ -237,20 +238,7 @@ ${e}`
}
},
wordCount: {
type: new GraphQLObjectType({
name: `wordCountsMdx`,
fields: {
paragraphs: {
type: GraphQLInt
},
sentences: {
type: GraphQLInt
},
words: {
type: GraphQLInt
}
}
}),
type: `MdxWordCount`,
async resolve(mdxNode) {
const { mdast } = await processMDX({ node: mdxNode });
return getCounts({ mdast });
Expand Down

0 comments on commit 15ae936

Please sign in to comment.