From 537fec49b2c9c4681ae091c64afd52c31efa9e4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Mu=CC=88ller?= Date: Thu, 1 Jul 2021 20:42:11 +0200 Subject: [PATCH] fix: skip Mdx nodes without absolute file path Plugins such as `gatsby-source-contentful` also create nodes with internal type `Mdx`, but do not add an absolute file path. Skipping Mdx nodes without absolute file path (from which we can derive the locale) seems ok since Contentful already handles localization. --- packages/gatsby-theme-i18n/gatsby-node.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/gatsby-theme-i18n/gatsby-node.js b/packages/gatsby-theme-i18n/gatsby-node.js index 2031881f..d0729c44 100644 --- a/packages/gatsby-theme-i18n/gatsby-node.js +++ b/packages/gatsby-theme-i18n/gatsby-node.js @@ -122,7 +122,11 @@ exports.onCreateNode = ({ node, actions }, themeOptions) => { const { defaultLang } = withDefaults(themeOptions) - if (node.internal.type === `Mdx`) { + if ( + node.internal.type === `Mdx` && + typeof node.fileAbsolutePath === `string` && + path.extname(node.fileAbsolutePath) === `.mdx` + ) { const name = path.basename(node.fileAbsolutePath, `.mdx`) const isDefault = name === `index`