mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-13 00:03:57 +02:00
feat(v2): allow config plugins as function or [function,options] (#4618)
* feat : update PluginSchema validation * feat : update plugin init functionality * test : add and update tests * fix : tests * refactor : init.ts * test : update test * docs : add functional plugin docs * fix little issues * refactor : refactor code * minor refactors * simplify initPlugins code * simplify initPlugin + add custom validation error message * fix snapshots * improve function plugin doc Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
e092910627
commit
69be003e12
16 changed files with 460 additions and 124 deletions
|
@ -90,24 +90,10 @@ describe('normalizeConfig', () => {
|
|||
|
||||
test.each([
|
||||
['should throw error if plugins is not array', {}],
|
||||
[
|
||||
'should throw error if plugins is not array',
|
||||
function () {
|
||||
console.log('noop');
|
||||
},
|
||||
],
|
||||
[
|
||||
"should throw error if plugins is not a string and it's not an array #1",
|
||||
[123],
|
||||
],
|
||||
[
|
||||
"should throw error if plugins is not a string and it's not an array #2",
|
||||
[
|
||||
function () {
|
||||
console.log('noop');
|
||||
},
|
||||
],
|
||||
],
|
||||
[
|
||||
'should throw error if plugins is not an array of [string, object][] #1',
|
||||
[['example/path', 'wrong parameter here']],
|
||||
|
@ -153,6 +139,11 @@ describe('normalizeConfig', () => {
|
|||
['this/should/work', {too: 'yes'}],
|
||||
],
|
||||
],
|
||||
['should accept function for plugin', [function (_context, _options) {}]],
|
||||
[
|
||||
'should accept [function, object] for plugin',
|
||||
[[function (_context, _options) {}, {it: 'should work'}]],
|
||||
],
|
||||
])(`%s for the input of: %p`, (_message, plugins) => {
|
||||
expect(() => {
|
||||
normalizeConfig({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue