Add docs on repeated use calls targeting the same plugin#80
Conversation
|
Sorry for letting this sit! (note we have a strict markdown code style so make sure to run Your line looks good but I think we should also add an example. What do you think of this, at the end of Note that when the same plugin is given multiple times, it will be attached
once and options are merged:
```js
var unified = require('unified')
unified()
.use(plugin, {alpha: true, bravo: true})
.use(plugin, {bravo: false, charlie: true})
// …
function plugin(options) {
console.log(options) // {alpha: true, bravo: false, charlie: true}
}
``` |
This comment has been minimized.
This comment has been minimized.
|
I'm finally getting back to this again. Just adapted the line length. I think the example would be a good addition, but I'm not sure where you're suggesting to put it? |
|
I was thinking right after the current example in that section? So right before this heading: https://github.com/unifiedjs/unified#processorparsefile |
|
One other suggestion - what would you think of including all examples in one piece of code as below? I think it would not add as much "clutter" var unified = require('unified')
unified()
// Plugin with options:
.use(pluginA, {x: true, y: true})
// Plugins:
.use([pluginB, pluginC])
// Two plugins, the second with options:
.use([pluginD, [pluginE, {}]])
// Preset with plugins and settings:
.use({plugins: [pluginF, [pluginG, {}]], settings: {position: false}})
// Settings only:
.use({settings: {position: false}})
// Updating options of pluginA (to {x: true, y: false, z: true}):
.use(pluginA, {y: false, z: true}) |
|
That’s a great idea!! ✨ I would do it immediately after // Plugin with options:
.use(pluginA, {x: true, y: true})
// Passing the same plugin again merges configuration (to `{x: true, y: false, z: true}`):
.use(pluginA, {y: false, z: true})Like so maybe? |
|
Sounds good, I've incorporated the changes |
use calls targeting the same plugin
|
Thank you! |
This adds the description discussed in #79