Skip to content

Commit

Permalink
pass plugin options to setParserPlugin
Browse files Browse the repository at this point in the history
some remark plugins require options to be passed to remark. for example,
`remark.use(parserPlugin, requiredPlugin)`. This commit passes the pluginOptions
to setParserPlugins. setParserPlugins returns an array of parsers. Now array elements
can also be arrays of two elements: parser, and options.
  • Loading branch information
AlahmadiQ8 committed Dec 21, 2017
1 parent 5835504 commit 25f438f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/gatsby-transformer-remark/src/extend-node-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,19 @@ module.exports = (
footnotes: true,
pedantic: true,
})

for (let plugin of pluginOptions.plugins) {
const requiredPlugin = require(plugin.resolve)
if (_.isFunction(requiredPlugin.setParserPlugins)) {
for (let parserPlugin of requiredPlugin.setParserPlugins()) {
remark = remark.use(parserPlugin)
for (let parserPlugin of requiredPlugin.setParserPlugins(
plugin.pluginOptions
)) {
if (_.isArray(parserPlugin)) {
const [parser, options] = parserPlugin
remark = remark.use(parser, options)
} else {
remark = remark.use(parserPlugin)
}
}
}
}
Expand Down

0 comments on commit 25f438f

Please sign in to comment.