mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 08:49:51 +02:00
docs(v2): update docs about creating a new plugin #2963
This commit is contained in:
parent
56067e4add
commit
4aa77651d3
1 changed files with 11 additions and 1 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue