Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
EricCote opened this issue Aug 17, 2022 · 4 comments
Open

Comments

@EricCote
Copy link

EricCote commented Aug 17, 2022

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
Copy link

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
Copy link
Author

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
Copy link

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

@donaldshen
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants