My Title
+ // highlight-end
);
```
Nested or latter components will override duplicate usages:
-```jsx {2,5,8,11}
+```jsx
+ {/* highlight-start */}
My Title
+ {/* highlight-end */}
+ {/* highlight-start */}
Nested Title
+ {/* highlight-end */}
```
@@ -111,16 +118,19 @@ The component is a wrapper around react-router’s `` component that adds
External links also work, and automatically have these props: `target="_blank" rel="noopener noreferrer"`.
-```jsx {2,7}
+```jsx
import React from 'react';
+// highlight-next-line
import Link from '@docusaurus/Link';
const Page = () => (
+ {/* highlight-next-line */}
Check out my blog!
+ {/* highlight-next-line */}
Follow me on Twitter!
@@ -147,11 +157,13 @@ Rendering a `` will navigate to a new location. The new location will
Example usage:
-```jsx {2,5}
+```jsx
import React from 'react';
+// highlight-next-line
import {Redirect} from '@docusaurus/router';
const Home = () => {
+ // highlight-next-line
return ;
};
```
@@ -358,17 +370,20 @@ interface DocusaurusContext {
Usage example:
-```jsx {5,8-10}
+```jsx
import React from 'react';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
const MyComponent = () => {
+ // highlight-next-line
const {siteConfig, siteMetadata} = useDocusaurusContext();
return (
;
+ // highlight-end
};
```
@@ -583,10 +607,9 @@ function interpolate(
#### Example {#example-1}
-```jsx
-// highlight-start
+```js
+// highlight-next-line
import {interpolate} from '@docusaurus/Interpolate';
-// highlight-end
const message = interpolate('Welcome {firstName}', {firstName: 'Sébastien'});
```
@@ -620,17 +643,14 @@ function translate(
import React from 'react';
import Layout from '@theme/Layout';
-// highlight-start
+// highlight-next-line
import {translate} from '@docusaurus/Translate';
-// highlight-end
export default function Home() {
return (
+ // highlight-next-line
+ title={translate({message: 'My page meta title'})}>
;
```
diff --git a/website/docs/guides/markdown-features/markdown-features-code-blocks.mdx b/website/docs/guides/markdown-features/markdown-features-code-blocks.mdx
index d3638dd7ba..42c9ad3340 100644
--- a/website/docs/guides/markdown-features/markdown-features-code-blocks.mdx
+++ b/website/docs/guides/markdown-features/markdown-features-code-blocks.mdx
@@ -34,7 +34,7 @@ function HelloCodeTitle(props) {
Code blocks are text blocks wrapped around by strings of 3 backticks. You may check out [this reference](https://github.com/mdx-js/specification) for the specifications of MDX.
- ```jsx
+ ```js
console.log('Every repo must come with a mascot.');
```
@@ -44,7 +44,7 @@ Use the matching language meta string for your code block, and Docusaurus will p
-```jsx
+```js
console.log('Every repo must come with a mascot.');
```
@@ -56,10 +56,11 @@ By default, the Prism [syntax highlighting theme](https://github.com/FormidableL
For example, if you prefer to use the `dracula` highlighting theme:
-```js {4} title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
themeConfig: {
prism: {
+ // highlight-next-line
theme: require('prism-react-renderer/themes/dracula'),
},
},
@@ -80,11 +81,12 @@ To add syntax highlighting for any of the other [Prism-supported languages](http
For example, if you want to add highlighting for the PowerShell language:
-```js {5} title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
// ...
themeConfig: {
prism: {
+ // highlight-next-line
additionalLanguages: ['powershell'],
},
// ...
@@ -102,14 +104,15 @@ npm run swizzle @docusaurus/theme-classic prism-include-languages
It will produce `prism-include-languages.js` in your `src/theme` folder. You can add highlighting support for custom languages by editing `prism-include-languages.js`:
-```js {8} title="src/theme/prism-include-languages.js"
+```js title="src/theme/prism-include-languages.js"
const prismIncludeLanguages = (Prism) => {
// ...
additionalLanguages.forEach((lang) => {
- require(`prismjs/components/prism-${lang}`); // eslint-disable-line
+ require(`prismjs/components/prism-${lang}`);
});
+ // highlight-next-line
require('/path/to/your/prism-language-definition');
// ...
@@ -124,7 +127,7 @@ You can refer to [Prism's official language definitions](https://github.com/Pris
You can use comments with `highlight-next-line`, `highlight-start`, and `highlight-end` to select which lines are highlighted.
- ```jsx
+ ```js
function HighlightSomeText(highlight) {
if (highlight) {
// highlight-next-line
@@ -148,7 +151,7 @@ You can use comments with `highlight-next-line`, `highlight-start`, and `highlig
````mdx-code-block
-```jsx
+```js
function HighlightSomeText(highlight) {
if (highlight) {
// highlight-next-line
@@ -348,9 +351,10 @@ By default, all React imports are available. If you need more imports available,
npm run swizzle @docusaurus/theme-live-codeblock ReactLiveScope
```
-```jsx {3-15,21} title="src/theme/ReactLiveScope/index.js"
+```jsx title="src/theme/ReactLiveScope/index.js"
import React from 'react';
+// highlight-start
const ButtonExample = (props) => (
-## Using JSX markup in code blocks {using-jsx-markup}
+## Using JSX markup in code blocks {#using-jsx-markup}
Code block in Markdown always preserves its content as plain text, meaning you can't do something like:
```ts
type EditUrlFunction = (params: {
- version: string;
// This doesn't turn into a link (for good reason!)
- // See doc versioning
+ version: Version;
versionDocsDirPath: string;
docPath: string;
permalink: string;
diff --git a/website/docs/guides/markdown-features/markdown-features-plugins.mdx b/website/docs/guides/markdown-features/markdown-features-plugins.mdx
index 3817b58869..821f7a4b7c 100644
--- a/website/docs/guides/markdown-features/markdown-features-plugins.mdx
+++ b/website/docs/guides/markdown-features/markdown-features-plugins.mdx
@@ -93,7 +93,7 @@ module.exports = {
Some plugins can be configured and accept their own options. In that case, use the `[plugin, pluginOptions]` syntax, like this:
-```jsx title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
presets: [
[
@@ -150,7 +150,7 @@ module.exports = plugin;
You can now import your plugin in `docusaurus.config.js` and use it just like an installed plugin!
-```jsx title="docusaurus.config.js"
+```js title="docusaurus.config.js"
// highlight-next-line
const sectionPrefix = require('./src/remark/section-prefix');
@@ -173,7 +173,7 @@ module.exports = {
The default plugins of Docusaurus would operate before the custom remark plugins, and that means the images or links have been converted to JSX with `require()` calls already. For example, in the example above, the table of contents generated is still the same even when all `h2` headings are now prefixed by `Section X.`, because the TOC-generating plugin is called before our custom plugin. If you need to process the MDAST before the default plugins do, use the `beforeDefaultRemarkPlugins` and `beforeDefaultRehypePlugins`.
-```jsx title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
presets: [
[
diff --git a/website/docs/migration/migration-manual.md b/website/docs/migration/migration-manual.md
index db34ba39ba..6b3faa7d60 100644
--- a/website/docs/migration/migration-manual.md
+++ b/website/docs/migration/migration-manual.md
@@ -135,7 +135,7 @@ In Docusaurus 2, we split each functionality (blog, docs, pages) into plugins fo
Add the following preset configuration to your `docusaurus.config.js`.
-```jsx title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
// ...
presets: [
@@ -217,7 +217,7 @@ import ColorGenerator from '@site/src/components/ColorGenerator';
Site meta info such as assets, SEO, copyright info are now handled by themes. To customize them, use the `themeConfig` field in your `docusaurus.config.js`:
-```jsx title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
// ...
themeConfig: {
@@ -251,7 +251,7 @@ headerLinks: [
Now, these two fields are both handled by the theme:
-```jsx {6-19} title="docusaurus.config.js"
+```js {6-19} title="docusaurus.config.js"
module.exports = {
// ...
themeConfig: {
@@ -279,7 +279,7 @@ module.exports = {
#### `algolia` {#algolia}
-```jsx {4-8} title="docusaurus.config.js"
+```js {4-8} title="docusaurus.config.js"
module.exports = {
// ...
themeConfig: {
@@ -305,7 +305,7 @@ You can contact the DocSearch team (@shortcuts, @s-pace) for support. They can u
Deprecated. Pass it as a blog option to `@docusaurus/preset-classic` instead:
-```jsx {8} title="docusaurus.config.js"
+```js {8} title="docusaurus.config.js"
module.exports = {
// ...
presets: [
@@ -332,7 +332,7 @@ Deprecated. Create a `CNAME` file in your `static` folder instead with your cust
Deprecated. Pass it as an option to `@docusaurus/preset-classic` docs instead:
-```jsx {8-20} title="docusaurus.config.js"
+```js {8-20} title="docusaurus.config.js"
module.exports = {
// ...
presets: [
@@ -363,7 +363,7 @@ module.exports = {
#### `gaTrackingId` {#gatrackingid}
-```jsx {5} title="docusaurus.config.js"
+```js {5} title="docusaurus.config.js"
module.exports = {
// ...
themeConfig: {
@@ -377,7 +377,7 @@ module.exports = {
#### `gaGtag` {#gagtag}
-```jsx {5} title="docusaurus.config.js"
+```js {5} title="docusaurus.config.js"
module.exports = {
// ...
themeConfig: {
diff --git a/website/docs/presets.md b/website/docs/presets.md
index 2b9fe3571c..148f1aa440 100644
--- a/website/docs/presets.md
+++ b/website/docs/presets.md
@@ -15,20 +15,22 @@ npm install --save @docusaurus/preset-classic
Then, add it in your site's `docusaurus.config.js`'s `presets` option:
-```jsx {3} title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
// ...
+ // highlight-next-line
presets: ['@docusaurus/preset-classic'],
};
```
To load presets from your local directory, specify how to resolve them:
-```jsx {5} title="docusaurus.config.js"
+```js title="docusaurus.config.js"
const path = require('path');
module.exports = {
// ...
+ // highlight-next-line
presets: [path.resolve(__dirname, '/path/to/docusaurus-local-presets')],
};
```
@@ -48,18 +50,22 @@ module.exports = function preset(context, opts = {}) {
then in your Docusaurus config, you may configure the preset instead:
-```jsx {3} title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
presets: [
- '@docusaurus/preset-my-own',
- {cool: {hello: 'world'}, blog: {path: '/blog'}},
+ // highlight-start
+ [
+ '@docusaurus/preset-my-own',
+ {cool: {hello: 'world'}, blog: {path: '/blog'}},
+ ],
+ // highlight-end
],
};
```
This is equivalent of doing:
-```jsx title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
themes: ['@docusaurus/themes-cool', {hello: 'world'}],
plugins: ['@docusaurus/plugin-blog', {path: '/blog'}],
diff --git a/website/docs/search.md b/website/docs/search.md
index ff53366992..9ff21a8c48 100644
--- a/website/docs/search.md
+++ b/website/docs/search.md
@@ -86,7 +86,7 @@ module.exports = {
Then, add an `algolia` field in your `themeConfig`. **[Apply for DocSearch](https://docsearch.algolia.com/apply/)** to get your Algolia index and API key.
-```jsx title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
// ...
themeConfig: {
@@ -142,7 +142,7 @@ To solve this problem, the contextual search feature understands that you are br
- browsing `/docs/v1/myDoc`, search results will only include **v1** docs (+ other unversioned pages)
- browsing `/docs/v2/myDoc`, search results will only include **v2** docs (+ other unversioned pages)
-```jsx title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
// ...
themeConfig: {
diff --git a/website/docs/styling-layout.md b/website/docs/styling-layout.md
index 9cfefeb0b9..edc8482e65 100644
--- a/website/docs/styling-layout.md
+++ b/website/docs/styling-layout.md
@@ -172,9 +172,10 @@ npm install --save docusaurus-plugin-sass sass
2. Include the plugin in your `docusaurus.config.js` file:
-```js {3} title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
// ...
+ // highlight-next-line
plugins: ['docusaurus-plugin-sass'],
// ...
};
@@ -186,7 +187,7 @@ module.exports = {
You can now set the `customCss` property of `@docusaurus/preset-classic` to point to your Sass/SCSS file:
-```js {8} title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
presets: [
[
@@ -194,6 +195,7 @@ module.exports = {
{
// ...
theme: {
+ // highlight-next-line
customCss: [require.resolve('./src/css/custom.scss')],
},
// ...
diff --git a/website/docs/using-plugins.md b/website/docs/using-plugins.md
index 695dceccde..302fd44025 100644
--- a/website/docs/using-plugins.md
+++ b/website/docs/using-plugins.md
@@ -19,20 +19,22 @@ npm install --save docusaurus-plugin-name
Then you add it in your site's `docusaurus.config.js`'s `plugins` option:
-```jsx {3} title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
// ...
+ // highlight-next-line
plugins: ['@docusaurus/plugin-content-pages'],
};
```
Docusaurus can also load plugins from your local directory, you can do something like the following:
-```jsx {5} title="docusaurus.config.js"
+```js title="docusaurus.config.js"
const path = require('path');
module.exports = {
// ...
+ // highlight-next-line
plugins: [path.resolve(__dirname, '/path/to/docusaurus-local-plugin')],
};
```
@@ -43,16 +45,18 @@ For the most basic usage of plugins, you can provide just the plugin name or the
However, plugins can have options specified by wrapping the name and an options object in an array inside your config. This style is usually called `Babel Style`.
-```js {4-9} title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
// ...
plugins: [
+ // highlight-start
[
'@docusaurus/plugin-xxx',
{
/* options */
},
],
+ // highlight-end
],
};
```
@@ -78,20 +82,15 @@ module.exports = {
## Multi-instance plugins and plugin ids {#multi-instance-plugins-and-plugin-ids}
-All Docusaurus content plugins can support multiple plugin instances.
+All Docusaurus content plugins can support multiple plugin instances. The Docs plugin has [additional multi-instance documentation](./guides/docs/docs-multi-instance.mdx). It is required to assign a unique id to each plugin instance, and by default, the plugin id is `default`.
-The Docs plugin has [additional multi-instance documentation](./guides/docs/docs-multi-instance.mdx)
-
-It is required to assign a unique id to each plugin instance.
-
-By default, the plugin id is `default`.
-
-```js {6,13} title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
plugins: [
[
'@docusaurus/plugin-xxx',
{
+ // highlight-next-line
id: 'plugin-xxx-1',
// other options
},
@@ -99,6 +98,7 @@ module.exports = {
[
'@docusaurus/plugin-xxx',
{
+ // highlight-next-line
id: 'plugin-xxx-2',
// other options
},
diff --git a/website/docs/using-themes.md b/website/docs/using-themes.md
index e6a626b3ce..a37e285d25 100644
--- a/website/docs/using-themes.md
+++ b/website/docs/using-themes.md
@@ -39,9 +39,10 @@ We maintain a [list of official themes](./api/themes/overview.md).
To use themes, specify the themes in your `docusaurus.config.js`. You may use multiple themes:
-```js {3} title="docusaurus.config.js"
+```js title="docusaurus.config.js"
module.exports = {
// ...
+ // highlight-next-line
themes: ['@docusaurus/theme-classic', '@docusaurus/theme-live-codeblock'],
};
```
@@ -228,14 +229,16 @@ To summarize:
A Docusaurus theme normally includes an `index.js` file where you hook up to the lifecycle methods, alongside a `theme/` directory of components. A typical Docusaurus `theme` folder looks like this:
-```bash {5-7}
+```bash
website
├── package.json
└── src
├── index.js
+ # highlight-start
└── theme
├── MyThemeComponent
└── AnotherThemeComponent.js
+ # highlight-end
```
There are two lifecycle methods that are essential to theme implementation: