From 76e8aac9504bb733942eef76803cd771202ed2f0 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Wed, 13 Jan 2021 11:38:43 +0100 Subject: [PATCH] add root and a TODO notice --- packages/gatsby-plugin-mdx/__tests__/gatsby-node.js | 3 +++ packages/gatsby-plugin-mdx/gatsby-node.js | 3 +++ packages/gatsby-plugin-mdx/utils/default-options.js | 1 + 3 files changed, 7 insertions(+) diff --git a/packages/gatsby-plugin-mdx/__tests__/gatsby-node.js b/packages/gatsby-plugin-mdx/__tests__/gatsby-node.js index e613a414b2ba1..0c7bacc5ae648 100644 --- a/packages/gatsby-plugin-mdx/__tests__/gatsby-node.js +++ b/packages/gatsby-plugin-mdx/__tests__/gatsby-node.js @@ -16,6 +16,7 @@ describe(`pluginOptionsSchema`, () => { `"mediaTypes[0]" must be a string`, `"mediaTypes[1]" must be a string`, `"shouldBlockNodeFromTransformation" must have an arity lesser or equal to 1`, + `"root" must be a string`, ] const { errors } = await testPluginOptionsSchema(pluginOptionsSchema, { @@ -27,6 +28,7 @@ describe(`pluginOptionsSchema`, () => { plugins: [2], mediaTypes: [1, 2], shouldBlockNodeFromTransformation: (wrong, number) => null, + root: 1, }) expect(errors).toEqual(expectedErrors) @@ -60,6 +62,7 @@ describe(`pluginOptionsSchema`, () => { ], mediaTypes: [`text/markdown`, `text/x-markdown`, `custom-media/type`], shouldBlockNodeFromTransformation: node => Boolean(node), + root: `james-holden`, }) expect(isValid).toBe(true) diff --git a/packages/gatsby-plugin-mdx/gatsby-node.js b/packages/gatsby-plugin-mdx/gatsby-node.js index 9e9c3f2984dd4..4d2099a4eb55a 100644 --- a/packages/gatsby-plugin-mdx/gatsby-node.js +++ b/packages/gatsby-plugin-mdx/gatsby-node.js @@ -122,5 +122,8 @@ exports.pluginOptionsSchema = function ({ Joi }) { .description( `Disable MDX transformation for nodes where this function returns true` ), + root: Joi.string() + .default(process.cwd()) + .description(`Who knows what this does lol`) }) } diff --git a/packages/gatsby-plugin-mdx/utils/default-options.js b/packages/gatsby-plugin-mdx/utils/default-options.js index 145cfa078b484..8512a183c289b 100644 --- a/packages/gatsby-plugin-mdx/utils/default-options.js +++ b/packages/gatsby-plugin-mdx/utils/default-options.js @@ -17,6 +17,7 @@ module.exports = ({ mdPlugins, hastPlugins, ...pluginOptions }) => { plugins: [], root: process.cwd(), gatsbyRemarkPlugins: [], + // TODO: Remove globalScope option in next major as it's deprecated in favor of shortcodes, see https://github.com/ChristopherBiscardi/gatsby-mdx/issues/239#issuecomment-507322221 globalScope: `export default {}`, shouldBlockNodeFromTransformation: () => false, },