Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jun 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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