mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-30 06:50:36 +02:00
feat(v2): option and config validation life cycle method for official plugins (#2943)
* add validation for blog plugin * fix wrong default component * fix test and add yup to package.json * remove console.log * add validation for classic theme and code block theme * add yup to packages * remove console.log * fix build * fix logo required * replaced yup with joi * fix test * remove hapi from docusuars core * replace joi with @hapi/joi * fix eslint * fix remark plugin type * change remark plugin validation to match documentation * move schema to it's own file * allow unknown only on outer theme object * fix type for schema type * fix yarn.lock * support both commonjs and ES modules * add docs for new lifecycle method
This commit is contained in:
parent
ce10646606
commit
81d855355e
18 changed files with 490 additions and 63 deletions
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
const path = require('path');
|
||||
const Joi = require('@hapi/joi');
|
||||
|
||||
module.exports = function () {
|
||||
return {
|
||||
|
@ -29,3 +30,21 @@ module.exports = function () {
|
|||
},
|
||||
};
|
||||
};
|
||||
|
||||
const ThemeConfigSchema = Joi.object({
|
||||
prism: Joi.object({
|
||||
theme: Joi.object({
|
||||
plain: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
|
||||
styles: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
|
||||
}),
|
||||
darkTheme: Joi.object({
|
||||
plain: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
|
||||
styles: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
|
||||
}),
|
||||
defaultLanguage: Joi.string(),
|
||||
}),
|
||||
});
|
||||
|
||||
module.exports.validateThemeConfig = ({validate, themeConfig}) => {
|
||||
return validate(ThemeConfigSchema, themeConfig);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue