gatsbyjs / themes

This is a repo for Gatsby's official themes.
138 stars 77 forks source link

gatsby-theme-i18n is incompatible with the new gatsby-plugin-mdx v4 #172

Open EricCote opened 2 years ago

EricCote commented 2 years ago

The new gatsby-plugin-mdx v4 has a lot of internal changes and new features.

Because of these internal changes, gatsby-theme-i18n fails to add the locale for .mdx files. Luckily, the fix is easy.

The error is in the gatsby-node.js file, on line 126.

Old Line:

  const name = path.basename(node.fileAbsolutePath, `.mdx`)

New Line:

// v3: fileAbsolutePath,  v4: contentFilePath
  const name = path.basename(node.fileAbsolutePath ?? node.contentFilePath, `.mdx`)

I'll do a pull request

gorzelinski commented 2 years ago

I was thinking the same thing. I even considered recreating the whole i18n logic to be able to use the new version of MDX. I don't know if that's the best solution, but I independently made an identical change in my local repo, and it worked.

EricCote commented 2 years ago

I published a fork of the i18n packages. (I needed that since this project doesn't seem to be updated anymore.) You can get them all here:

Source code with example is here, but on branch "publish-fork": https://github.com/ericcote/themes/tree/publish-fork

If this can help someone, I am happy about that...

@LekoArts, do you know if there are plans for a better i18n story with Gatsby v5?

gorzelinski commented 2 years ago

It seems like it, unfortunately. Thanks. I'll check them out in my free time.

donaldshen commented 1 year ago

I published a fork of the i18n packages. (I needed that since this project doesn't seem to be updated anymore.) You can get them all here:

Source code with example is here, but on branch "publish-fork": https://github.com/ericcote/themes/tree/publish-fork

If this can help someone, I am happy about that...

@LekoArts, do you know if there are plans for a better i18n story with Gatsby v5?

You save my day.