From 20930dc83718c99407547aec5bc909935a7bfbb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Wed, 24 Jun 2020 20:13:32 +0200 Subject: [PATCH] docs(v2): add plugin redirects production build note (#2983) * add plugin redirects production build note * Update using-plugins.md Co-authored-by: Yangshun Tay --- website/docs/using-plugins.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/website/docs/using-plugins.md b/website/docs/using-plugins.md index 775bc0912a..1ebb8d0f19 100644 --- a/website/docs/using-plugins.md +++ b/website/docs/using-plugins.md @@ -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.