mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-31 09:57:03 +02:00
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:
parent
81d855355e
commit
20930dc837
1 changed files with 14 additions and 5 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue