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

docs(website): use .mdx extension for every docs #8490

Merged
merged 3 commits into from Dec 30, 2022

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Dec 29, 2022

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:

brew install rename
find docs -type f -name "*.md" -exec rename 's/\.md$/.mdx/' '{}' \;
find versioned_docs -type f -name "*.md" -exec rename 's/\.md$/.mdx/' '{}' \;
find blog -type f -name "*.md" -exec rename 's/\.md$/.mdx/' '{}' \;

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:

  • From: \((?<url>(?!http)[^ ]*?)(?<ext>\.md)(?<hash>#[^ ]+)?\)
  • To: (${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:

CleanShot 2022-12-30 at 15 10 32@2x

Test Plan

preview

Test links

Deploy preview: https://deploy-preview-8490--docusaurus-2.netlify.app/

Related issues/PRs

@slorber slorber added the pr: documentation This PR works on the website or other text documents in the repo. label Dec 29, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Dec 29, 2022
@netlify
Copy link

netlify bot commented Dec 29, 2022

[V2]

Name Link
🔨 Latest commit 76a789e
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/63aee86cd065c9000827ed7b
😎 Deploy Preview https://deploy-preview-8490--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented Dec 29, 2022

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟢 94 🟢 97 🟢 100 🟢 100 🟢 90 Report
/docs/installation 🟠 80 🟢 100 🟢 100 🟢 100 🟢 90 Report

@github-actions
Copy link

github-actions bot commented Dec 29, 2022

Size Change: +253 B (0%)

Total Size: 889 kB

Filename Size Change
website/build/assets/js/main.********.js 665 kB +253 B (0%)
ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 71 kB
website/build/assets/css/styles.********.css 112 kB
website/build/index.html 40.9 kB

compressed-size-action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: documentation This PR works on the website or other text documents in the repo.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants