mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-20 12:37:01 +02:00
chore(v2): prepare v2.0.0-beta.0 release (#4774)
* beta.0 version docs + changelog * fix config for beta switch * v2.0.0-beta.0
This commit is contained in:
parent
fe6492aa87
commit
7e4d7671c8
103 changed files with 11779 additions and 149 deletions
|
@ -0,0 +1,78 @@
|
|||
---
|
||||
id: plugins
|
||||
title: Plugins
|
||||
description: Using MDX plugins to expand Docusaurus Markdown functionalities
|
||||
slug: /markdown-features/plugins
|
||||
---
|
||||
|
||||
You can expand the MDX functionalities, using plugins.
|
||||
|
||||
Docusaurus content plugins support both [Remark](https://github.com/remarkjs/remark) and [Rehype](https://github.com/rehypejs/rehype) plugins that work with MDX.
|
||||
|
||||
## Configuring plugins {#configuring-plugins}
|
||||
|
||||
An MDX plugin is usually a npm package, so you install them like other npm packages using npm.
|
||||
|
||||
First, install your [Remark](https://github.com/remarkjs/remark/blob/main/doc/plugins.md#list-of-plugins) and [Rehype](https://github.com/rehypejs/rehype/blob/main/doc/plugins.md#list-of-plugins) plugins.
|
||||
|
||||
For example:
|
||||
|
||||
```bash npm2yarn
|
||||
npm install --save remark-images
|
||||
npm install --save rehype-truncate
|
||||
```
|
||||
|
||||
Next, import the plugins:
|
||||
|
||||
```js
|
||||
const remarkImages = require('remark-images');
|
||||
const rehypeTruncate = require('rehype-truncate');
|
||||
```
|
||||
|
||||
Finally, add them to the `@docusaurus/preset-classic` options in `docusaurus.config.js`:
|
||||
|
||||
```js {10,11} title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
// ...
|
||||
presets: [
|
||||
[
|
||||
'@docusaurus/preset-classic',
|
||||
{
|
||||
docs: {
|
||||
sidebarPath: require.resolve('./sidebars.js'),
|
||||
// ...
|
||||
remarkPlugins: [remarkImages],
|
||||
rehypePlugins: [rehypeTruncate],
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
## Configuring plugin options {#configuring-plugin-options}
|
||||
|
||||
Some plugins can be configured and accept their own options. In that case, use the `[plugin, pluginOptions]` syntax, like so:
|
||||
|
||||
```jsx {10-13} title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
// ...
|
||||
presets: [
|
||||
[
|
||||
'@docusaurus/preset-classic',
|
||||
{
|
||||
docs: {
|
||||
sidebarPath: require.resolve('./sidebars.js'),
|
||||
// ...
|
||||
remarkPlugins: [
|
||||
plugin1,
|
||||
[plugin2, {option1: {...}}],
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
See more information in the [MDX documentation](https://mdxjs.com/advanced/plugins).
|
Loading…
Add table
Add a link
Reference in a new issue