Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-plugin-mdx): allow plugins: [...] in options schema #27709

Merged
merged 2 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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