Skip to content

Commit

Permalink
docs(v2): add plugin redirects production build note (#2983)
Browse files Browse the repository at this point in the history
* add plugin redirects production build note

* Update using-plugins.md

Co-authored-by: Yangshun Tay <[email protected]>
  • Loading branch information
slorber and yangshun authored Jun 24, 2020
1 parent 81d8553 commit 20930dc
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions website/docs/using-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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`

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 20930dc

Please sign in to comment.