docs(v2): add plugin redirects production build note (#2983)

* add plugin redirects production build note

* Update using-plugins.md

Co-authored-by: Yangshun Tay <tay.yang.shun@gmail.com>
This commit is contained in:
Sébastien Lorber 2020-06-24 20:13:32 +02:00 committed by GitHub
parent 81d855355e
commit 20930dc837
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,10 +84,14 @@ A plugin is a module which exports a function that takes two parameters and retu
The exported modules for plugins are called with two parameters: `context` and `options` and returns a JavaScript object with defining the [lifecycle APIs](./lifecycle-apis.md).
For example if you have a reference to a local folder such as this in your
docusaurus.config.js:
For example if you have a reference to a local folder such as this in your `docusaurus.config.js`:
plugins: [path.resolve(__dirname, 'my-plugin')],
```js title="docusaurus.config.js"
module.exports = {
// ...
plugins: [path.resolve(__dirname, 'my-plugin')],
};
```
Then in the folder `my-plugin` you can create an index.js such as this
@ -103,8 +107,7 @@ module.exports = function(context, options) {
};
```
The `my-plugin` folder could also be a fully fledged package with it's own
package.json and a `src/index.js` file for example
The `my-plugin` folder could also be a fully fledged package with it's own package.json and a `src/index.js` file for example
#### `context`
@ -475,6 +478,12 @@ Docusaurus Plugin to generate **client-side redirects**.
This plugin will write additional HTML pages to your static site, that redirects the user to your existing Docusaurus pages with JavaScript.
:::note
This plugin only create redirects for the production build.
:::
:::caution
It is better to use server-side redirects whenever possible.