Skip to content

Commit 21f24f8

Browse files
authored
fix(gatsby-plugin-mdx): remark/hypePlugins options schema (#27698)
* fix(gatsby-plugin-mdx): remark/hypePlugins options schema * Fix typo * Fix tests
1 parent fcb22eb commit 21f24f8

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe(`pluginOptionsSchema`, () => {
77
`"extensions[0]" must be a string`,
88
`"extensions[1]" must be a string`,
99
`"extensions[2]" must be a string`,
10-
`"defaultLayout" must be of type object`,
10+
`"defaultLayouts" must be of type object`,
1111
`"gatsbyRemarkPlugins[0]" does not match any of the allowed types`,
1212
`"gatsbyRemarkPlugins[1]" does not match any of the allowed types`,
1313
`"remarkPlugins" must be an array`,
@@ -19,7 +19,7 @@ describe(`pluginOptionsSchema`, () => {
1919

2020
const { errors } = await testPluginOptionsSchema(pluginOptionsSchema, {
2121
extensions: [1, 2, 3],
22-
defaultLayout: `this should be an object`,
22+
defaultLayouts: `this should be an object`,
2323
gatsbyRemarkPlugins: [1, { not: `existing prop` }, `valid one`],
2424
remarkPlugins: `this should be an array of object`,
2525
rehypePlugins: `this should be an array of object`,
@@ -33,7 +33,7 @@ describe(`pluginOptionsSchema`, () => {
3333
it(`should validate the schema`, async () => {
3434
const { isValid } = await testPluginOptionsSchema(pluginOptionsSchema, {
3535
extensions: [`.mdx`, `.mdxx`],
36-
defaultLayout: {
36+
defaultLayouts: {
3737
posts: `../post-layout.js`,
3838
default: `../default-layout.js`,
3939
},

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const fs = require(`fs`)
66

77
const {
88
onCreateNode,
9-
unstable_shouldOnCreateNode
9+
unstable_shouldOnCreateNode,
1010
} = require(`./gatsby/on-create-node`)
1111

1212
/**
@@ -77,7 +77,7 @@ if (process.env.GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION) {
7777
.description(
7878
`Configure the file extensions that gatsby-plugin-mdx will process`
7979
),
80-
defaultLayout: Joi.object({})
80+
defaultLayouts: Joi.object({})
8181
.unknown(true)
8282
.default({})
8383
.description(`Set the layout components for MDX source types`),
@@ -94,17 +94,31 @@ if (process.env.GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION) {
9494
remarkPlugins: Joi.array()
9595
.items(
9696
Joi.alternatives().try(
97-
Joi.object({}).unknown(true),
98-
Joi.array().items(Joi.object({}).unknown(true))
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+
)
99107
)
100108
)
101109
.default([])
102110
.description(`Specify remark plugins`),
103111
rehypePlugins: Joi.array()
104112
.items(
105113
Joi.alternatives().try(
114+
Joi.function(),
106115
Joi.object({}).unknown(true),
107-
Joi.array().items(Joi.object({}).unknown(true))
116+
Joi.array().items(
117+
Joi.alternatives().try(
118+
Joi.object({}).unknown(true),
119+
Joi.function()
120+
)
121+
)
108122
)
109123
)
110124
.default([])

0 commit comments

Comments
 (0)