mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
refactor(theme): split admonitions, make swizzle easier, better retrocompatibility (#7945)
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
This commit is contained in:
parent
f1415525c0
commit
6f63ffe0a3
32 changed files with 914 additions and 236 deletions
|
@ -20,7 +20,7 @@ You now need to swizzle the admonitions component to provide UI customizations s
|
|||
Please refer to https://github.com/facebook/docusaurus/pull/7152 for detailed upgrade instructions."
|
||||
`;
|
||||
|
||||
exports[`validation schemas admonitionsSchema: for value={"keywords":[]} 1`] = `""keywords" does not contain 1 required value(s)"`;
|
||||
exports[`validation schemas admonitionsSchema: for value={"keywords":["custom-keyword"],"extendDefaults":42} 1`] = `""extendDefaults" must be a boolean"`;
|
||||
|
||||
exports[`validation schemas admonitionsSchema: for value={"tag":""} 1`] = `""tag" is not allowed to be empty"`;
|
||||
|
||||
|
|
|
@ -96,13 +96,20 @@ describe('validation schemas', () => {
|
|||
testOK({});
|
||||
testOK({tag: '+++'});
|
||||
testOK({keywords: ['info', 'tip']});
|
||||
testOK({keywords: ['info', 'tip'], extendDefaults: true});
|
||||
testOK({keywords: ['info', 'tip'], extendDefaults: false});
|
||||
testOK({keywords: []});
|
||||
testOK({keywords: [], extendDefaults: true}); // noop
|
||||
testOK({keywords: [], extendDefaults: false}); // disable admonitions
|
||||
testOK({tag: '+++', keywords: ['info', 'tip']});
|
||||
testOK({tag: '+++', keywords: ['custom-keyword'], extendDefaults: true});
|
||||
testOK({tag: '+++', keywords: ['custom-keyword'], extendDefaults: false});
|
||||
|
||||
testFail(3);
|
||||
testFail([]);
|
||||
testFail({unknownAttribute: 'val'});
|
||||
testFail({tag: ''});
|
||||
testFail({keywords: []});
|
||||
testFail({keywords: ['custom-keyword'], extendDefaults: 42});
|
||||
|
||||
// Legacy types
|
||||
testFail({
|
||||
|
|
|
@ -44,8 +44,12 @@ export const AdmonitionsSchema = JoiFrontMatter.alternatives()
|
|||
JoiFrontMatter.object({
|
||||
tag: JoiFrontMatter.string(),
|
||||
keywords: JoiFrontMatter.array().items(
|
||||
JoiFrontMatter.string().required(),
|
||||
JoiFrontMatter.string(),
|
||||
// Apparently this is how we tell job to accept empty arrays...
|
||||
// .required(),
|
||||
),
|
||||
extendDefaults: JoiFrontMatter.boolean(),
|
||||
|
||||
// TODO Remove before 2023
|
||||
customTypes: LegacyAdmonitionConfigSchema,
|
||||
icons: LegacyAdmonitionConfigSchema,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue