From 4aa77651d3771f5bcddfa1728754d8a1892e6b8b Mon Sep 17 00:00:00 2001 From: Colin Diesh Date: Fri, 19 Jun 2020 09:32:36 -0400 Subject: [PATCH] docs(v2): update docs about creating a new plugin #2963 --- website/docs/using-plugins.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/website/docs/using-plugins.md b/website/docs/using-plugins.md index eab4d30789..775bc0912a 100644 --- a/website/docs/using-plugins.md +++ b/website/docs/using-plugins.md @@ -84,7 +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). -```js title="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')], + +Then in the folder `my-plugin` you can create an index.js such as this + +```js title="index.js" module.exports = function(context, options) { // ... return { @@ -96,6 +103,9 @@ 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 + #### `context` `context` is plugin-agnostic and the same object will be passed into all plugins used for a Docusaurus website. The `context` object contains the following fields: