docs(website): use .mdx extension for every docs #8490
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
As part of the MDX 2 migration (#8288)
We want MDX docs to have the .md extension
If you want to use CommonMark (which we don't for our own website here), you could still use .md extension.
Using MDX syntax with the .md extension (like many Docusaurus sites do historically) is problematic for tooling integration (IDE, Prettier etc...)
How to migrate
Change file extensions
On macos:
You should find a similar alternative for your own OS to automate this.
Change Markdown links
We want:
[link](doc.md)
=>[link](doc.mdx)
[link](doc.md#anchor)
=>[link](doc.mdx#anchor)
[link](https://github.com/facebook/docusaurus/blob/main/README.md)
=>[link](https://github.com/facebook/docusaurus/blob/main/README.md)
(not updated on purpose because absolute URL)With IntelliJ regexp replace:
\((?<url>(?!http)[^ ]*?)(?<ext>\.md)(?<hash>#[^ ]+)?\)
(${url}.mdx${hash})
You can probably do a similar thing with your own IDE or CLI tools.
If you need something more reliable than a regexp because of a few edge cases, you can try writing a Remark plugin to parse Markdown and process its links with a visitor.
i18n notes
.md files on Crowdin should be renamed to .mdx
In practice it's not really possible to change a file extension on Crowdin, but you should be able to re-upload .mdx files, and then delete .md files and translations should not be lost if you use Crowdin settings for String Deduplication:
Test Plan
preview
Test links
Deploy preview: https://deploy-preview-8490--docusaurus-2.netlify.app/
Related issues/PRs