Skip to content

Commit

Permalink
fix(gatsby-plugin-mdx): allow plugins: [...] in options schema (#27709)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxstbr committed Oct 30, 2020
1 parent 2a50aa0 commit f8cf904
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
3 changes: 3 additions & 0 deletions packages/gatsby-plugin-mdx/__tests__/gatsby-node.js
Expand Up @@ -12,6 +12,7 @@ describe(`pluginOptionsSchema`, () => {
`"gatsbyRemarkPlugins[1]" does not match any of the allowed types`,
`"remarkPlugins" must be an array`,
`"rehypePlugins" must be an array`,
`"plugins[0]" does not match any of the allowed types`,
`"mediaTypes[0]" must be a string`,
`"mediaTypes[1]" must be a string`,
`"shouldBlockNodeFromTransformation" must have an arity lesser or equal to 1`,
Expand All @@ -23,6 +24,7 @@ describe(`pluginOptionsSchema`, () => {
gatsbyRemarkPlugins: [1, { not: `existing prop` }, `valid one`],
remarkPlugins: `this should be an array of object`,
rehypePlugins: `this should be an array of object`,
plugins: [2],
mediaTypes: [1, 2],
shouldBlockNodeFromTransformation: (wrong, number) => null,
})
Expand Down Expand Up @@ -50,6 +52,7 @@ describe(`pluginOptionsSchema`, () => {
require(`../gatsby-node.js`),
[require(`../gatsby-node.js`), { target: false }],
],
plugins: [{ resolve: `remark-autolink-plugin` }],
rehypePlugins: [
require(`../gatsby-node.js`),
[require(`../gatsby-node.js`), { behavior: `wrap` }],
Expand Down
29 changes: 7 additions & 22 deletions packages/gatsby-plugin-mdx/gatsby-node.js
Expand Up @@ -93,36 +93,21 @@ if (process.env.GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION) {
.description(`Use Gatsby-specific remark plugins`),
remarkPlugins: Joi.array()
.items(
Joi.alternatives().try(
Joi.alternatives().try(
Joi.function(),
Joi.object({}).unknown(true),
Joi.array().items(
Joi.alternatives().try(
Joi.object({}).unknown(true),
Joi.function()
)
)
)
)
Joi.function(),
Joi.object({}).unknown(true),
Joi.array().items(Joi.object({}).unknown(true), Joi.function())
)
.default([])
.description(`Specify remark plugins`),
rehypePlugins: Joi.array()
.items(
Joi.alternatives().try(
Joi.function(),
Joi.object({}).unknown(true),
Joi.array().items(
Joi.alternatives().try(
Joi.object({}).unknown(true),
Joi.function()
)
)
)
Joi.function(),
Joi.object({}).unknown(true),
Joi.array().items(Joi.object({}).unknown(true), Joi.function())
)
.default([])
.description(`Specify rehype plugins`),
plugins: Joi.array().items(Joi.string(), Joi.object({}).unknown(true)),
mediaTypes: Joi.array()
.items(Joi.string())
.default(["text/markdown", "text/x-markdown"])
Expand Down

0 comments on commit f8cf904

Please sign in to comment.