Skip to content

Commit f8cf904

Browse files
authored
fix(gatsby-plugin-mdx): allow plugins: [...] in options schema (#27709)
1 parent 2a50aa0 commit f8cf904

File tree

2 files changed

+10
-22
lines changed

2 files changed

+10
-22
lines changed

packages/gatsby-plugin-mdx/__tests__/gatsby-node.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ describe(`pluginOptionsSchema`, () => {
1212
`"gatsbyRemarkPlugins[1]" does not match any of the allowed types`,
1313
`"remarkPlugins" must be an array`,
1414
`"rehypePlugins" must be an array`,
15+
`"plugins[0]" does not match any of the allowed types`,
1516
`"mediaTypes[0]" must be a string`,
1617
`"mediaTypes[1]" must be a string`,
1718
`"shouldBlockNodeFromTransformation" must have an arity lesser or equal to 1`,
@@ -23,6 +24,7 @@ describe(`pluginOptionsSchema`, () => {
2324
gatsbyRemarkPlugins: [1, { not: `existing prop` }, `valid one`],
2425
remarkPlugins: `this should be an array of object`,
2526
rehypePlugins: `this should be an array of object`,
27+
plugins: [2],
2628
mediaTypes: [1, 2],
2729
shouldBlockNodeFromTransformation: (wrong, number) => null,
2830
})
@@ -50,6 +52,7 @@ describe(`pluginOptionsSchema`, () => {
5052
require(`../gatsby-node.js`),
5153
[require(`../gatsby-node.js`), { target: false }],
5254
],
55+
plugins: [{ resolve: `remark-autolink-plugin` }],
5356
rehypePlugins: [
5457
require(`../gatsby-node.js`),
5558
[require(`../gatsby-node.js`), { behavior: `wrap` }],

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

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -93,36 +93,21 @@ if (process.env.GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION) {
9393
.description(`Use Gatsby-specific remark plugins`),
9494
remarkPlugins: Joi.array()
9595
.items(
96-
Joi.alternatives().try(
97-
Joi.alternatives().try(
98-
Joi.function(),
99-
Joi.object({}).unknown(true),
100-
Joi.array().items(
101-
Joi.alternatives().try(
102-
Joi.object({}).unknown(true),
103-
Joi.function()
104-
)
105-
)
106-
)
107-
)
96+
Joi.function(),
97+
Joi.object({}).unknown(true),
98+
Joi.array().items(Joi.object({}).unknown(true), Joi.function())
10899
)
109100
.default([])
110101
.description(`Specify remark plugins`),
111102
rehypePlugins: Joi.array()
112103
.items(
113-
Joi.alternatives().try(
114-
Joi.function(),
115-
Joi.object({}).unknown(true),
116-
Joi.array().items(
117-
Joi.alternatives().try(
118-
Joi.object({}).unknown(true),
119-
Joi.function()
120-
)
121-
)
122-
)
104+
Joi.function(),
105+
Joi.object({}).unknown(true),
106+
Joi.array().items(Joi.object({}).unknown(true), Joi.function())
123107
)
124108
.default([])
125109
.description(`Specify rehype plugins`),
110+
plugins: Joi.array().items(Joi.string(), Joi.object({}).unknown(true)),
126111
mediaTypes: Joi.array()
127112
.items(Joi.string())
128113
.default(["text/markdown", "text/x-markdown"])

0 commit comments

Comments
 (0)