Skip to content

Commit cd150b5

Browse files
andrewbranchpieh
authored andcommitted
fix(gatsby-plugin-mdx): Pass node API helpers from onCreateNode and sourceNodes to remark plugins (#20879)
* [gatsby-plugin-mdx] Pass node API helpers from onCreateNode to remark plugins * Fix sourceNodes too
1 parent 3f2ce1e commit cd150b5

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

packages/gatsby-plugin-mdx/gatsby/on-create-node.js

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module.exports = async (
2121
reporter,
2222
cache,
2323
pathPrefix,
24+
...helpers
2425
},
2526
pluginOptions
2627
) => {
@@ -64,6 +65,10 @@ module.exports = async (
6465
cache,
6566
pathPrefix,
6667
options,
68+
loadNodeContent,
69+
actions,
70+
createNodeId,
71+
...helpers,
6772
},
6873
{ forceDisableCache: true }
6974
)

packages/gatsby-plugin-mdx/gatsby/source-nodes.js

+24-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,17 @@ async function getCounts({ mdast }) {
5252
}
5353

5454
module.exports = (
55-
{ store, pathPrefix, getNode, getNodes, cache, reporter, actions, schema },
55+
{
56+
store,
57+
pathPrefix,
58+
getNode,
59+
getNodes,
60+
cache,
61+
reporter,
62+
actions,
63+
schema,
64+
...helpers
65+
},
5666
pluginOptions
5767
) => {
5868
let mdxHTMLLoader
@@ -105,7 +115,19 @@ module.exports = (
105115
}
106116

107117
const processMDX = ({ node }) =>
108-
genMDX({ node, getNode, getNodes, reporter, cache, pathPrefix, options })
118+
genMDX({
119+
node,
120+
options,
121+
store,
122+
pathPrefix,
123+
getNode,
124+
getNodes,
125+
cache,
126+
reporter,
127+
actions,
128+
schema,
129+
...helpers,
130+
})
109131

110132
// New Code // Schema
111133
const MdxType = schema.buildObjectType({

packages/gatsby-plugin-mdx/utils/gen-mdx.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,17 @@ const BabelPluginPluckImports = require(`./babel-plugin-pluck-imports`)
4040
* */
4141

4242
module.exports = async function genMDX(
43-
{ isLoader, node, options, getNode, getNodes, reporter, cache, pathPrefix },
43+
{
44+
isLoader,
45+
node,
46+
options,
47+
getNode,
48+
getNodes,
49+
reporter,
50+
cache,
51+
pathPrefix,
52+
...helpers
53+
},
4454
{ forceDisableCache = false } = {}
4555
) {
4656
const pathPrefixCacheStr = pathPrefix || ``
@@ -106,6 +116,7 @@ export const _frontmatter = ${JSON.stringify(data)}`
106116
reporter,
107117
cache,
108118
pathPrefix,
119+
...helpers,
109120
}
110121
)
111122

packages/gatsby-plugin-mdx/utils/get-source-plugins-as-remark-plugins.js

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = async function getSourcePluginsAsRemarkPlugins({
1616
reporter,
1717
cache,
1818
pathPrefix,
19+
...helpers
1920
}) {
2021
debug(`getSourcePluginsAsRemarkPlugins`)
2122
let pathPlugin = undefined
@@ -63,6 +64,7 @@ module.exports = async function getSourcePluginsAsRemarkPlugins({
6364
pathPrefix,
6465
reporter,
6566
cache,
67+
...helpers,
6668
},
6769
plugin.options || {}
6870
)

0 commit comments

Comments
 (0)