Skip to content

Commit 120b99b

Browse files
authored
docs(website): use .mdx extension for every docs (#8490)
1 parent 428af8a commit 120b99b

308 files changed

Lines changed: 1050 additions & 1009 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.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ Although you (either plugin authors or site creators) are writing JavaScript all
2525

2626
Plugin code and theme code never directly import each other: they only communicate through protocols (in our case, through JSON temp files and calls to `addRoute`). A useful mental model is to imagine that the plugins are not written in JavaScript, but in another language like Rust. The only way to interact with plugins for the user is through `docusaurus.config.js`, which itself is run in Node (hence you can use `require` and pass callbacks as plugin options).
2727

28-
During bundling, the config file itself is serialized and bundled, allowing the theme to access config options like `themeConfig` or `baseUrl` through [`useDocusaurusContext()`](../docusaurus-core.md#useDocusaurusContext). However, the `siteConfig` object only contains **serializable values** (values that are preserved after `JSON.stringify()`). Functions, regexes, etc. would be lost on the client side. The `themeConfig` is designed to be entirely serializable.
28+
During bundling, the config file itself is serialized and bundled, allowing the theme to access config options like `themeConfig` or `baseUrl` through [`useDocusaurusContext()`](../docusaurus-core.mdx#useDocusaurusContext). However, the `siteConfig` object only contains **serializable values** (values that are preserved after `JSON.stringify()`). Functions, regexes, etc. would be lost on the client side. The `themeConfig` is designed to be entirely serializable.

website/versioned_docs/version-2.1.0/advanced/client.md renamed to website/docs/advanced/client.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ These modules are imported globally before React even renders the initial UI.
9191
import '@generated/client-modules';
9292
```
9393

94-
Plugins and sites can both declare client modules, through [`getClientModules`](../api/plugin-methods/lifecycle-apis.md#getClientModules) and [`siteConfig.clientModules`](../api/docusaurus.config.js.md#clientModules), respectively.
94+
Plugins and sites can both declare client modules, through [`getClientModules`](../api/plugin-methods/lifecycle-apis.mdx#getClientModules) and [`siteConfig.clientModules`](../api/docusaurus.config.js.mdx#clientModules), respectively.
9595

96-
Client modules are called during server-side rendering as well, so remember to check the [execution environment](./ssg.md#escape-hatches) before accessing client-side globals.
96+
Client modules are called during server-side rendering as well, so remember to check the [execution environment](./ssg.mdx#escape-hatches) before accessing client-side globals.
9797

9898
```js title="mySiteGlobalJs.js"
9999
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
@@ -108,7 +108,7 @@ if (ExecutionEnvironment.canUseDOM) {
108108
}
109109
```
110110

111-
CSS stylesheets imported as client modules are [global](../styling-layout.md#global-styles).
111+
CSS stylesheets imported as client modules are [global](../styling-layout.mdx#global-styles).
112112

113113
```css title="mySiteGlobalCss.css"
114114
/* This stylesheet is global. */
@@ -181,6 +181,6 @@ Both lifecycles will fire on first render, but they will not fire on server-side
181181
182182
:::tip Prefer using React
183183
184-
Client module lifecycles are purely imperative, and you can't use React hooks or access React contexts within them. If your operations are state-driven or involve complicated DOM manipulations, you should consider [swizzling components](../swizzling.md) instead.
184+
Client module lifecycles are purely imperative, and you can't use React hooks or access React contexts within them. If your operations are state-driven or involve complicated DOM manipulations, you should consider [swizzling components](../swizzling.mdx) instead.
185185
186186
:::

website/versioned_docs/version-2.2.0/advanced/index.md renamed to website/docs/advanced/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ import DocCardList from '@theme/DocCardList';
88
<DocCardList />
99
```
1010

11-
We will assume that you have finished the guides, and know the basics like how to configure plugins, how to write React components, etc. These sections will have plugin authors and code contributors in mind, so we may occasionally refer to [plugin APIs](../api/plugin-methods/README.md) or other architecture details. Don't panic if you don't understand everything😉
11+
We will assume that you have finished the guides, and know the basics like how to configure plugins, how to write React components, etc. These sections will have plugin authors and code contributors in mind, so we may occasionally refer to [plugin APIs](../api/plugin-methods/README.mdx) or other architecture details. Don't panic if you don't understand everything😉

website/versioned_docs/version-2.1.0/advanced/plugins.md renamed to website/docs/advanced/plugins.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Plugins are the building blocks of features in a Docusaurus 2 site. Each plugin
44

55
## Creating plugins {#creating-plugins}
66

7-
A plugin is a function that takes two parameters: `context` and `options`. It returns a plugin instance object (or a promise). You can create plugins as functions or modules. For more information, refer to the [plugin method references section](../api/plugin-methods/README.md).
7+
A plugin is a function that takes two parameters: `context` and `options`. It returns a plugin instance object (or a promise). You can create plugins as functions or modules. For more information, refer to the [plugin method references section](../api/plugin-methods/README.mdx).
88

99
### Function definition {#function-definition}
1010

@@ -86,7 +86,7 @@ Docusaurus' implementation of the plugins system provides us with a convenient w
8686

8787
### Theme design {#theme-design}
8888

89-
When plugins have loaded their content, the data is made available to the client side through actions like [`createData` + `addRoute`](../api/plugin-methods/lifecycle-apis.md#addRoute) or [`setGlobalData`](../api/plugin-methods/lifecycle-apis.md#setGlobalData). This data has to be _serialized_ to plain strings, because [plugins and themes run in different environments](./architecture.md). Once the data arrives on the client side, the rest becomes familiar to React developers: data is passed along components, components are bundled with Webpack, and rendered to the window through `ReactDOM.render`...
89+
When plugins have loaded their content, the data is made available to the client side through actions like [`createData` + `addRoute`](../api/plugin-methods/lifecycle-apis.mdx#addRoute) or [`setGlobalData`](../api/plugin-methods/lifecycle-apis.mdx#setGlobalData). This data has to be _serialized_ to plain strings, because [plugins and themes run in different environments](./architecture.mdx). Once the data arrives on the client side, the rest becomes familiar to React developers: data is passed along components, components are bundled with Webpack, and rendered to the window through `ReactDOM.render`...
9090

9191
**Themes provide the set of UI components to render the content.** Most content plugins need to be paired with a theme in order to be actually useful. The UI is a separate layer from the data schema, which makes swapping designs easy.
9292

@@ -120,7 +120,7 @@ Now, although the theme receives the same data from the plugin, how the theme ch
120120

121121
While themes share the exact same lifecycle methods with plugins, themes' implementations can look very different from those of plugins based on themes' designed objectives.
122122

123-
Themes are designed to complete the build of your Docusaurus site and supply the components used by your site, plugins, and the themes themselves. A theme still acts like a plugin and exposes some lifecycle methods, but most likely they would not use [`loadContent`](../api/plugin-methods/lifecycle-apis.md#loadContent), since they only receive data from plugins, but don't generate data themselves; themes are typically also accompanied by an `src/theme` directory full of components, which are made known to the core through the [`getThemePath`](../api/plugin-methods/extend-infrastructure.md#getThemePath) lifecycle.
123+
Themes are designed to complete the build of your Docusaurus site and supply the components used by your site, plugins, and the themes themselves. A theme still acts like a plugin and exposes some lifecycle methods, but most likely they would not use [`loadContent`](../api/plugin-methods/lifecycle-apis.mdx#loadContent), since they only receive data from plugins, but don't generate data themselves; themes are typically also accompanied by an `src/theme` directory full of components, which are made known to the core through the [`getThemePath`](../api/plugin-methods/extend-infrastructure.mdx#getThemePath) lifecycle.
124124

125125
To summarize:
126126

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ graph LR;
3838

3939
Any route will be matched against this nested route config until a good match is found. For example, when given a route `/docs/configuration`, Docusaurus first enters the `/docs` branch, and then searches among the subroutes created by the docs plugin.
4040

41-
Changing `routeBasePath` can effectively alter your site's route structure. For example, in [Docs-only mode](../guides/docs/docs-introduction.md#docs-only-mode), we mentioned that configuring `routeBasePath: '/'` for docs means that all routes that the docs plugin create would not have the `/docs` prefix, yet it doesn't prevent you from having more subroutes like `/blog` created by other plugins.
41+
Changing `routeBasePath` can effectively alter your site's route structure. For example, in [Docs-only mode](../guides/docs/docs-introduction.mdx#docs-only-mode), we mentioned that configuring `routeBasePath: '/'` for docs means that all routes that the docs plugin create would not have the `/docs` prefix, yet it doesn't prevent you from having more subroutes like `/blog` created by other plugins.
4242

4343
Next, let's look at how the three plugins structure their own "boxes of subroutes".
4444

4545
### Pages routing {#pages-routing}
4646

47-
Pages routing are straightforward: the file paths directly map to URLs, without any other way to customize. See the [pages docs](../guides/creating-pages.md#routing) for more information.
47+
Pages routing are straightforward: the file paths directly map to URLs, without any other way to customize. See the [pages docs](../guides/creating-pages.mdx#routing) for more information.
4848

4949
The component used for Markdown pages is `@theme/MDXPage`. React pages are directly used as the route's component.
5050

@@ -71,7 +71,7 @@ The blog creates the following routes:
7171

7272
### Docs routing {#docs-routing}
7373

74-
The docs is the only plugin that creates **nested routes**. At the top, it registers [**version paths**](../guides/docs/versioning.md): `/`, `/next`, `/2.0.0-beta.13`... which provide the version context, including the layout and sidebar. This ensures that when switching between individual docs, the sidebar's state is preserved, and that you can switch between versions through the navbar dropdown while staying on the same doc. The component used is `@theme/DocPage`.
74+
The docs is the only plugin that creates **nested routes**. At the top, it registers [**version paths**](../guides/docs/versioning.mdx): `/`, `/next`, `/2.0.0-beta.13`... which provide the version context, including the layout and sidebar. This ensures that when switching between individual docs, the sidebar's state is preserved, and that you can switch between versions through the navbar dropdown while staying on the same doc. The component used is `@theme/DocPage`.
7575

7676
```mdx-code-block
7777
export const URLPath = () => <code>{useLocation().pathname}</code>;
@@ -221,7 +221,7 @@ Localized sites have the locale as part of the base URL as well. For example, `h
221221

222222
## Generating and accessing routes {#generating-and-accessing-routes}
223223

224-
The `addRoute` lifecycle action is used to generate routes. It registers a piece of route config to the route tree, giving a route, a component, and props that the component needs. The props and the component are both provided as paths for the bundler to `require`, because as explained in the [architecture overview](architecture.md), server and client only communicate through temp files.
224+
The `addRoute` lifecycle action is used to generate routes. It registers a piece of route config to the route tree, giving a route, a component, and props that the component needs. The props and the component are both provided as paths for the bundler to `require`, because as explained in the [architecture overview](architecture.mdx), server and client only communicate through temp files.
225225

226226
All routes are aggregated in `.docusaurus/routes.js`, which you can view with the debug plugin's [routes panel](/__docusaurus/debug/routes).
227227

website/versioned_docs/version-2.1.0/advanced/ssg.md renamed to website/docs/advanced/ssg.mdx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Docusaurus statically renders your React code into HTML, allowing f
55

66
# Static site generation (SSG)
77

8-
In [architecture](architecture.md), we mentioned that the theme is run in Webpack. But beware: that doesn't mean it always has access to browser globals! The theme is built twice:
8+
In [architecture](architecture.mdx), we mentioned that the theme is run in Webpack. But beware: that doesn't mean it always has access to browser globals! The theme is built twice:
99

1010
- During **server-side rendering**, the theme is compiled in a sandbox called [React DOM Server](https://reactjs.org/docs/react-dom-server.html). You can see this as a "headless browser", where there is no `window` or `document`, only React. SSR produces static HTML pages.
1111
- During **client-side rendering**, the theme is compiled to JavaScript that gets eventually executed in the browser, so it has access to browser variables.
@@ -57,7 +57,8 @@ export default function expensiveComp() {
5757

5858
During Webpack build, the `process.env.NODE_ENV` will be replaced with the value, either `'development'` or `'production'`. You will then get different build results after dead code elimination:
5959

60-
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
60+
import Tabs from '@theme/Tabs';
61+
import TabItem from '@theme/TabItem';
6162

6263
```mdx-code-block
6364
<Tabs>
@@ -105,7 +106,7 @@ export default function expensiveComp() {
105106

106107
React is not just a dynamic UI runtime—it's also a templating engine. Because Docusaurus sites mostly contain static contents, it should be able to work without any JavaScript (which React runs in), but only plain HTML/CSS. And that's what server-side rendering offers: statically rendering your React code into HTML, without any dynamic content. An HTML file has no concept of client state (it's purely markup), hence it shouldn't rely on browser APIs.
107108

108-
These HTML files are the first to arrive at the user's browser screen when a URL is visited (see [routing](routing.md)). Afterwards, the browser fetches and runs other JS code to provide the "dynamic" parts of your site—anything implemented with JavaScript. However, before that, the main content of your page is already visible, allowing faster loading.
109+
These HTML files are the first to arrive at the user's browser screen when a URL is visited (see [routing](routing.mdx)). Afterwards, the browser fetches and runs other JS code to provide the "dynamic" parts of your site—anything implemented with JavaScript. However, before that, the main content of your page is already visible, allowing faster loading.
109110

110111
In CSR-only apps, all DOM elements are generated on client side with React, and the HTML file only ever contains one root element for React to mount DOM to; in SSR, React is already facing a fully built HTML page, and it only needs to correlate the DOM elements with the virtual DOM in its model. This step is called "hydration". After React has hydrated the static markup, the app starts to work as any normal React app.
111112

@@ -135,7 +136,7 @@ We provide several more reliable ways to escape SSR.
135136

136137
### `<BrowserOnly>` {#browseronly}
137138

138-
If you need to render some component in browser only (for example, because the component relies on browser specifics to be functional at all), one common approach is to wrap your component with [`<BrowserOnly>`](../docusaurus-core.md#browseronly) to make sure it's invisible during SSR and only rendered in CSR.
139+
If you need to render some component in browser only (for example, because the component relies on browser specifics to be functional at all), one common approach is to wrap your component with [`<BrowserOnly>`](../docusaurus-core.mdx#browseronly) to make sure it's invisible during SSR and only rendered in CSR.
139140

140141
```jsx
141142
import BrowserOnly from '@docusaurus/BrowserOnly';
@@ -204,7 +205,7 @@ function MyComponent() {
204205

205206
### `ExecutionEnvironment` {#executionenvironment}
206207

207-
The [`ExecutionEnvironment`](../docusaurus-core.md#executionenvironment) namespace contains several values, and `canUseDOM` is an effective way to detect browser environment.
208+
The [`ExecutionEnvironment`](../docusaurus-core.mdx#executionenvironment) namespace contains several values, and `canUseDOM` is an effective way to detect browser environment.
208209

209210
Beware that it essentially checked `typeof window !== 'undefined'` under the hood, so you should not use it for rendering-related logic, but only imperative code, like reacting to user input by sending web requests, or dynamically importing libraries, where DOM isn't updated at all.
210211

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Refer to the [deployment guide](../deployment.mdx) and [slorber/trailing-slash-g
119119

120120
- Type: `Object`
121121

122-
The i18n configuration object to [localize your site](../i18n/i18n-introduction.md).
122+
The i18n configuration object to [localize your site](../i18n/i18n-introduction.mdx).
123123

124124
Example:
125125

@@ -201,7 +201,7 @@ By default, it prints a warning, to let you know about your broken Markdown link
201201

202202
- Type: `'ignore' | 'log' | 'warn' | 'throw'`
203203

204-
The behavior of Docusaurus when it detects any [duplicate routes](/guides/creating-pages.md#duplicate-routes).
204+
The behavior of Docusaurus when it detects any [duplicate routes](/guides/creating-pages.mdx#duplicate-routes).
205205

206206
By default, it displays a warning after you run `yarn start` or `yarn build`.
207207

@@ -283,7 +283,7 @@ module.exports = {
283283

284284
- Type: `Object`
285285

286-
The [theme configuration](./themes/theme-configuration.md) object to customize your site UI like navbar and footer.
286+
The [theme configuration](./themes/theme-configuration.mdx) object to customize your site UI like navbar and footer.
287287

288288
Example:
289289

@@ -354,7 +354,7 @@ module.exports = {
354354
type PluginConfig = string | [string, any] | PluginModule | [PluginModule, any];
355355
```
356356

357-
See [plugin method references](./plugin-methods/README.md) for the shape of a `PluginModule`.
357+
See [plugin method references](./plugin-methods/README.mdx) for the shape of a `PluginModule`.
358358

359359
```js title="docusaurus.config.js"
360360
module.exports = {
@@ -530,7 +530,7 @@ By default, the `<link>` tags will have `rel="stylesheet"`, but you can explicit
530530

531531
### `clientModules` {#clientModules}
532532

533-
An array of [client modules](../advanced/client.md#client-modules) to load globally on your site.
533+
An array of [client modules](../advanced/client.mdx#client-modules) to load globally on your site.
534534

535535
Example:
536536

File renamed without changes.

website/docs/api/misc/eslint-plugin/README.md renamed to website/docs/api/misc/eslint-plugin/README.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ For more fine-grained control, you can also enable the plugin manually and confi
5050

5151
| Name | Description | |
5252
| --- | --- | --- |
53-
| [`@docusaurus/no-untranslated-text`](./no-untranslated-text.md) | Enforce text labels in JSX to be wrapped by translate calls | |
54-
| [`@docusaurus/string-literal-i18n-messages`](./string-literal-i18n-messages.md) | Enforce translate APIs to be called on plain text labels ||
55-
| [`@docusaurus/no-html-links`](./no-html-links.md) | Ensures @docusaurus/Link is used instead of `<a>` tags ||
53+
| [`@docusaurus/no-untranslated-text`](./no-untranslated-text.mdx) | Enforce text labels in JSX to be wrapped by translate calls | |
54+
| [`@docusaurus/string-literal-i18n-messages`](./string-literal-i18n-messages.mdx) | Enforce translate APIs to be called on plain text labels ||
55+
| [`@docusaurus/no-html-links`](./no-html-links.mdx) | Ensures @docusaurus/Link is used instead of `<a>` tags ||
5656

5757
✅ = recommended
5858

website/docs/api/misc/eslint-plugin/no-html-links.md renamed to website/docs/api/misc/eslint-plugin/no-html-links.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ slug: /api/misc/@docusaurus/eslint-plugin/no-html-links
44

55
# no-html-links
66

7-
Ensure that the Docusaurus [`<Link>`](../../../docusaurus-core.md#link) component is used instead of `<a>` tags.
7+
Ensure that the Docusaurus [`<Link>`](../../../docusaurus-core.mdx#link) component is used instead of `<a>` tags.
88

99
The `<Link>` component has prefetching and preloading built-in. It also does build-time broken link detection, and helps Docusaurus understand your site's structure better.
1010

0 commit comments

Comments
 (0)