Skip to content

Commit caff1c4

Browse files
authored
chore(website): migrate MDX heading ids to comment syntax + upgrade Crowdin parser version (facebook#11779)
1 parent 9456b23 commit caff1c4

1,018 files changed

Lines changed: 9406 additions & 9498 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

crowdin-v2.yaml

Lines changed: 19 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
#
2-
# Your Crowdin credentials
3-
#
1+
# Crowdin credentials
42
project_id: '428890'
53
api_token_env: CROWDIN_PERSONAL_TOKEN
64
# base_path: '.'
75
# base_url: https://api.crowdin.com
86

9-
#
10-
# Choose file structure in Crowdin
11-
# e.g. true or false
12-
#
137
preserve_hierarchy: true
148

159
# We generally want to use the "two-letters-code" of a locale (ie the language)
@@ -20,18 +14,24 @@ languages_mapping: &languages_mapping
2014
two_letters_code:
2115
pt-BR: pt-BR
2216

23-
# Crowdin regularly update their MDX parser
24-
# Unfortunately, their v2 parser is more "MDX compliant" and thus can't parse
25-
# Docusaurus MDX files correctly due to our custom {#headingId} syntax.
26-
# Adding this type param permits using their older v1.2 parser.
27-
# Note: you can find the version of a file using browser DevTools
28-
# The source file icons will have a class such as "file_type_mdx_v1_2"
29-
#
30-
# TODO fix our headingId syntax
31-
# providing an explicit type is annoying and not future-proof
32-
# there's a risk that when adding an image in /docs, it will be parsed as mdx
33-
# and duplicating source file configs for various extensions is not great either
34-
mdx_file_type: &mdx_file_type mdx_v1_2
17+
# Crowdin regularly update their MDX parser, leading to subtle breakage.
18+
# Freezing the parser to a specific version is helpful to ensure things keep
19+
# working when they upgrade their MDX parser.
20+
# See https://github.com/facebook/docusaurus/pull/11432
21+
#
22+
# Note: you can find the parser version of a Crowdin file using browser DevTools
23+
# and inspecting the MDX file icon, it should have a class ".file_type_mdx_v1_2"
24+
# Find the latest version: manually upload a new .mdx file, then inspect it
25+
#
26+
# How to upgrade the parser version?
27+
# - Rename /docs to /docs_backup on Crowdin UI (same for other mdx folders)
28+
# - Update the parser version of this config file
29+
# - Use the CLI to re-upload the MDX source files: they should now have the new parser version
30+
# - Use the CLI to download the translations
31+
# - Build the full i18n site to ensure it still works (the new parser might break things)
32+
# - Make sure the site content remains translated (normally /docs & /docs_backup share the translation strings)
33+
# - If things work well, you can merge the config update and delete the mdx backup folders on Crowdin UI
34+
mdx_file_type: &mdx_file_type mdx_v2_4
3535

3636
#
3737
# Files configuration
@@ -71,100 +71,3 @@ files:
7171
translation: /website/i18n/%two_letters_code%/docusaurus-plugin-content-pages/**/%original_file_name%
7272
ignore: [/**/*.js, /**/*.jsx, /**/*.ts, /**/*.tsx, /**/*.css]
7373
languages_mapping: *languages_mapping
74-
#
75-
# Source files filter
76-
# e.g. "/resources/en/*.json"
77-
#
78-
#"source" : "/website/docs/**/*.md",
79-
#
80-
# Where translations will be placed
81-
# e.g. "/resources/docs/%two_letters_code%/%original_file_name%"
82-
#
83-
#"translation" : "/website/i18n/%language%/docs/current/%original_file_name%",
84-
#
85-
# Files or directories for ignore
86-
# e.g. ["/**/?.txt", "/**/[0-9].txt", "/**/*\?*.txt"]
87-
#
88-
#"ignore" : [],
89-
#
90-
# The dest allows you to specify a file name in Crowdin
91-
# e.g. "/messages.json"
92-
#
93-
#"dest" : "",
94-
#
95-
# File type
96-
# e.g. "json"
97-
#
98-
#"type" : "",
99-
#
100-
# The parameter "update_option" is optional. If it is not set, after the files update the translations for changed strings will be removed. Use to fix typos and for minor changes in the source strings
101-
# e.g. "update_as_unapproved" or "update_without_changes"
102-
#
103-
#"update_option" : "",
104-
#
105-
# Start block (for XML only)
106-
#
107-
#
108-
# Defines whether to translate tags attributes.
109-
# e.g. 0 or 1 (Default is 1)
110-
#
111-
# "translate_attributes" : 1,
112-
#
113-
# Defines whether to translate texts placed inside the tags.
114-
# e.g. 0 or 1 (Default is 1)
115-
#
116-
# "translate_content" : 1,
117-
#
118-
# This is an array of strings, where each item is the XPaths to DOM element that should be imported
119-
# e.g. ["/content/text", "/content/text[@value]"]
120-
#
121-
# "translatable_elements" : [],
122-
#
123-
# Defines whether to split long texts into smaller text segments
124-
# e.g. 0 or 1 (Default is 1)
125-
#
126-
# "content_segmentation" : 1,
127-
#
128-
# End block (for XML only)
129-
#
130-
#
131-
# Start .properties block
132-
#
133-
#
134-
# Defines whether single quote should be escaped by another single quote or backslash in exported translations
135-
# e.g. 0 or 1 or 2 or 3 (Default is 3)
136-
# 0 - do not escape single quote;
137-
# 1 - escape single quote by another single quote;
138-
# 2 - escape single quote by backslash;
139-
# 3 - escape single quote by another single quote only in strings containing variables ( {0} ).
140-
#
141-
# "escape_quotes" : 3,
142-
#
143-
# Defines whether any special characters (=, :, ! and #) should be escaped by backslash in exported translations.
144-
# e.g. 0 or 1 (Default is 0)
145-
# 0 - do not escape special characters
146-
# 1 - escape special characters by a backslash
147-
#
148-
# "escape_special_characters": 0
149-
#
150-
#
151-
# End .properties block
152-
#
153-
#
154-
# Often software projects have custom names for the directories where translations are placed. crowdin-cli allows you to map your own languages to be understandable by Crowdin.
155-
#
156-
#"languages_mapping" : {
157-
# "two_letters_code" : {
158-
# "crowdin_language_code" : "local_name"
159-
# }
160-
#},
161-
#
162-
# Does the first line contain header?
163-
# e.g. true or false
164-
#
165-
#"first_line_contains_header" : true,
166-
#
167-
# for spreadsheets
168-
# e.g. "identifier,source_phrase,context,uk,ru,fr"
169-
#
170-
# "scheme" : "",

packages/docusaurus/src/commands/writeHeadingIds.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ export async function writeHeadingIds(
109109
} else {
110110
logger.warn`number=${
111111
markdownFiles.length
112-
} Markdown files already have explicit heading IDs. If you intend to overwrite the existing heading IDs, use the code=${'--overwrite'} option.`;
112+
} Markdown files already have explicit heading IDs.
113+
If you intend to overwrite the existing heading IDs, use the code=${'--overwrite'} option.
114+
If you intend to change their heading ID syntax, use the code=${'--migrate'} option.`;
113115
}
114116
}

website/_dogfooding/_docs tests/tests/links/target.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ slug: target-doc-slug
66

77
This is just a doc meant to be linked to by other docs.
88

9-
## Target heading {#target-heading}
9+
## Target heading \{#target-heading}

website/_dogfooding/_pages tests/markdown-tests-mdx.mdx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,19 @@ sequenceDiagram
188188
Bob-->>John: Jolly good!
189189
```
190190

191-
## Custom heading ID {#custom}
191+
## Classic heading ID syntax \{#classic-heading-id-syntax}
192192

193-
### Weird heading {#你好}
193+
Dogfood that the classic heading ID syntax `{#id}` remains supported on MDX docs. It requires manual escaping with `\{#id}` since we disabled the MDX v1 compat layer (`markdown.mdx1Compat.headingIds`).
194194

195-
### Weird heading {#2022.1.1}
195+
### Weird heading \{#你好}
196196

197-
### Weird heading {#a#b}
197+
### Weird heading \{#2022.1.1}
198198

199-
### Weird heading {#a b}
199+
### Weird heading \{#a#b}
200200

201-
### Weird heading {#a\{b}
201+
### Weird heading \{#a b}
202+
203+
### Weird heading \{#a\{b}
202204

203205
## Pipe
204206

website/blog/2017/12-14-introducing-docusaurus.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ We created [Docusaurus](https://docusaurus.io) for the following reasons:
1515
1. To make it easy to push updates, new features, and bug fixes to everyone all at once.
1616
1. And, finally, to provide a consistent look and feel across all of our open source projects.
1717

18-
<!--truncate-->
18+
{/* truncate */}
1919

2020
Docusaurus is a tool designed to make it easy for teams to publish documentation websites without having to worry about the infrastructure and design details. At its core, all a user has to provide are documentation files written in Markdown, customization of a provided home page written in React, and a few configuration modifications. Docusaurus handles the rest by providing default styles, site formatting, and simple document navigation. Getting started is easy, as users can [install](https://v1.docusaurus.io/docs/en/installation.html) it using `npm` or `yarn` via a simple initialization script that [creates a working example website out of the box](https://v1.docusaurus.io/docs/en/site-preparation.html).
2121

2222
Docusaurus also provides core website and documentation features out-of-the-box including [blog support](https://v1.docusaurus.io/docs/en/blog.html), [internationalization](https://v1.docusaurus.io/docs/en/translation.html), [search](https://v1.docusaurus.io/docs/en/search.html), and [versioning](https://v1.docusaurus.io/docs/en/versioning.html). While some projects may not require any of these features, enabling them is generally a matter of updating configuration options instead of having to add the infrastructure from the ground up. As more features get added to Docusaurus, users just can easily update to the latest version. This can be done by simply running npm or yarn update and updating configuration options. Users or teams will no longer need to manually rework their entire website infrastructure each time a new feature gets added.
2323

24-
## The Birth of docusaurus
24+
## The Birth of docusaurus {/* #the-birth-of-docusaurus */}
2525

2626
![](/img/slash-birth.png)
2727

@@ -37,7 +37,7 @@ Docusaurus was born!
3737

3838
At Facebook, Docusaurus allows us to quickly get different projects up and running with documentation websites, especially for teams who don't have much experience with web development or primarily want a basic site to showcase their project. Docusaurus already supports sites needing more advanced features like internationalization for Jest and versioning for React Native. As different projects request new features for their sites, they are added to Docusaurus and simultaneously provided to all projects! All together, this ends up greatly reducing the work needed to maintain different sites for different projects. Our teams are able to focus on keeping their projects healthier by spending more time adding features, fixing bugs, and writing documentation.
3939

40-
## Getting Up and Running
40+
## Getting Up and Running {/* #getting-up-and-running */}
4141

4242
![](/img/slash-up-and-running.png)
4343

@@ -69,7 +69,7 @@ root-of-repo
6969

7070
With the exception of node_modules and package.json, all the directories and files you see are where you customize and add content to your Docusaurus-based website. The docs folder is where you add your Markdown that represents your documentation; the blog folder is where you add your Markdown for your [blog posts](https://v1.docusaurus.io/docs/en/blog.html); `siteConfig.js` is where you make most of the [customizations](https://v1.docusaurus.io/docs/en/site-config.html) for your site; `sidebars.json` is where you maintain the layout and content of the [sidebar](https://v1.docusaurus.io/docs/en/navigation.html) for your documentation; the `pages` folder is where you add [custom](https://v1.docusaurus.io/docs/en/custom-pages.html) pages for your site; the `static` folder is where all of your static assets go (e.g., CSS stylesheets and images); and the `core` folder is where you can customize core components of the site, in this case the footer.
7171

72-
## How does Docusaurus work?
72+
## How does Docusaurus work? {/* #how-does-docusaurus-work */}
7373

7474
Docusaurus is written primarily in JavaScript and [React](https://facebook.github.io/react), replacing Jekyll which we used in the old template. We use [Remarkable](https://github.com/jonschlinkert/remarkable) for our Markdown rendering and [highlight.js](https://highlightjs.org/) for our code block syntax highlighting. The core of Docusaurus' functionality is in the [lib directory](https://github.com/facebookexperimental/Docusaurus/tree/master/lib) of the [Docusaurus repo](https://github.com/facebook/docusaurus/). The general structure looks like:
7575

@@ -125,13 +125,13 @@ build
125125
│ └── users.html # custom page
126126
```
127127

128-
## Community
128+
## Community {/* #community */}
129129

130130
![](/img/docusaurus.svg)
131131

132132
We welcome your [contributions](https://github.com/facebook/docusaurus/blob/master/CONTRIBUTING.md) to Docusaurus, whether you want to use it for your own site, you want to [contribute](https://github.com/facebook/docusaurus/blob/master/CONTRIBUTING.md) to the Docusaurus core or just have questions. Follow us on [GitHub](https://github.com/facebook/docusaurus) and [X)](https://x.com/docusaurus).
133133

134-
## Acknowledgements
134+
## Acknowledgements {/* #acknowledgements */}
135135

136136
Docusaurus wouldn't exist without the work of the rest of the core Docusaurus team: [Eric Nakagawa](http://x.com/ericnakagawa), [Hector Ramos](https://x.com/hectorramos), [Eric Vicenti](https://x.com/EricVicenti) and [Frank Li](https://github.com/deltice) — a former intern at Facebook who implemented the core technology and features.
137137

@@ -148,7 +148,7 @@ Special thanks also goes out to our earliest [adopters](https://v1.docusaurus.io
148148

149149
Without their dedication to creating or migrating their websites over to the platform, we would have not have been in the position where we are today.
150150

151-
## Resources
151+
## Resources {/* #resources */}
152152

153153
- [Read our documentation](https://v1.docusaurus.io)
154154
- [Follow our X feed](https://x.com/docusaurus)

website/blog/2018/04-30-How-I-Converted-Profilo-To-Docusaurus.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This is the story of the rather short journey it took to create the [Profilo](ht
1212

1313
Profilo, an Android library for collecting performance traces from production, [was announced](https://code.fb.com/android/profilo-understanding-app-performance-in-the-wild/) earlier this year. The project was [published on GitHub](https://github.com/facebookincubator/profilo/tree/802042f90f990998a272387e371b893af52465b8) with a less than [a handful or Markdown files](https://github.com/facebookincubator/profilo/tree/802042f90f990998a272387e371b893af52465b8/docs) to describe its functionality and no website to showcase any branding and highlight the logo. The task at hand was to turn these existing docs and logo into a website.
1414

15-
<!--truncate-->
15+
{/* truncate */}
1616

1717
In general, when creating a website with Docusaurus you do the following:
1818

@@ -26,7 +26,7 @@ In general, when creating a website with Docusaurus you do the following:
2626

2727
Given I had pre-existing Markdown files, I didn't have to generate the core content but simply make sure that Docusaurus could process the files by adding the expected metadata to them. Most of the work would therefore consist of customizing the defaults provided by Docusaurus.
2828

29-
## Overview of Steps Taken
29+
## Overview of Steps Taken {/* #overview-of-steps-taken */}
3030

3131
Here's an overview of the steps taken to convert to a website. I'll discuss some of the design aspects in a later section.
3232

@@ -83,7 +83,7 @@ Here's an overview of the steps taken to convert to a website. I'll discuss some
8383

8484
The final website was published on https://facebookincubator.github.io/profilo/. It had taken 1.5 hours to get to the initial PR stage and another half an hour or so to respond to review feedback and publish the website.
8585

86-
## Design
86+
## Design {/* #design */}
8787

8888
Here's what the initial website looked like when the first pull request was sent out:
8989

@@ -115,7 +115,7 @@ Lastly, I didn't have to worry about handling responsive design. You get this ou
115115

116116
![Mobile screenshots of the front page and sample doc page. The layout is automatically adjusted to make it appear more natural. The doc sidebar is hidden behind a button.](/img/profilo_blog_post_android_ios.png)
117117

118-
## Final Thoughts
118+
## Final Thoughts {/* #final-thoughts */}
119119

120120
The Profilo engineers were happy to see that they didn't have to change their workflow to update existing content. They were able to continue working with Markdown files. This will still be true in the future if new docs are added, although there may be some config changes needed if the sidebar navigation needs to be updated.
121121

0 commit comments

Comments
 (0)