mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-02 11:47:23 +02:00
fix(v2): make config validation less strict (#3120)
* fix(v2): make navbar title validation less strict * fix(v2): fix validation for rehype plugin * fix(v2): allow empty string for routeBasePath * fix(v2): fix validation for stylesheets and scripts field * fix(v2): rerun CI * fix(v2): relax check for stylesheet href
This commit is contained in:
parent
41d5ac63fd
commit
2159c4fcfb
4 changed files with 26 additions and 16 deletions
|
@ -28,7 +28,7 @@ export const DEFAULT_OPTIONS = {
|
|||
|
||||
export const PluginOptionSchema = Joi.object({
|
||||
path: Joi.string().default(DEFAULT_OPTIONS.path),
|
||||
routeBasePath: Joi.string().default(DEFAULT_OPTIONS.routeBasePath),
|
||||
routeBasePath: Joi.string().allow('').default(DEFAULT_OPTIONS.routeBasePath),
|
||||
include: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.include),
|
||||
postsPerPage: Joi.number()
|
||||
.integer()
|
||||
|
@ -45,16 +45,19 @@ export const PluginOptionSchema = Joi.object({
|
|||
showReadingTime: Joi.bool().default(DEFAULT_OPTIONS.showReadingTime),
|
||||
remarkPlugins: Joi.array()
|
||||
.items(
|
||||
Joi.alternatives().try(
|
||||
Joi.function(),
|
||||
Joi.array()
|
||||
.items(Joi.function().required(), Joi.object().required())
|
||||
.length(2),
|
||||
),
|
||||
Joi.array()
|
||||
.items(Joi.function().required(), Joi.object().required())
|
||||
.length(2),
|
||||
Joi.function(),
|
||||
)
|
||||
.default(DEFAULT_OPTIONS.remarkPlugins),
|
||||
rehypePlugins: Joi.array()
|
||||
.items(Joi.string())
|
||||
.items(
|
||||
Joi.array()
|
||||
.items(Joi.function().required(), Joi.object().required())
|
||||
.length(2),
|
||||
Joi.function(),
|
||||
)
|
||||
.default(DEFAULT_OPTIONS.rehypePlugins),
|
||||
editUrl: Joi.string().uri(),
|
||||
truncateMarker: Joi.object().default(DEFAULT_OPTIONS.truncateMarker),
|
||||
|
|
|
@ -29,7 +29,7 @@ export const DEFAULT_OPTIONS: PluginOptions = {
|
|||
export const PluginOptionSchema = Joi.object({
|
||||
path: Joi.string().default(DEFAULT_OPTIONS.path),
|
||||
editUrl: Joi.string().uri(),
|
||||
routeBasePath: Joi.string().default(DEFAULT_OPTIONS.routeBasePath),
|
||||
routeBasePath: Joi.string().allow('').default(DEFAULT_OPTIONS.routeBasePath),
|
||||
homePageId: Joi.string().default(DEFAULT_OPTIONS.homePageId),
|
||||
include: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.include),
|
||||
sidebarPath: Joi.string().default(DEFAULT_OPTIONS.sidebarPath),
|
||||
|
@ -37,12 +37,19 @@ export const PluginOptionSchema = Joi.object({
|
|||
docItemComponent: Joi.string().default(DEFAULT_OPTIONS.docItemComponent),
|
||||
remarkPlugins: Joi.array()
|
||||
.items(
|
||||
Joi.array().items(Joi.function(), Joi.object()).length(2),
|
||||
Joi.array()
|
||||
.items(Joi.function().required(), Joi.object().required())
|
||||
.length(2),
|
||||
Joi.function(),
|
||||
)
|
||||
.default(DEFAULT_OPTIONS.remarkPlugins),
|
||||
rehypePlugins: Joi.array()
|
||||
.items(Joi.string())
|
||||
.items(
|
||||
Joi.array()
|
||||
.items(Joi.function().required(), Joi.object().required())
|
||||
.length(2),
|
||||
Joi.function(),
|
||||
)
|
||||
.default(DEFAULT_OPTIONS.rehypePlugins),
|
||||
showLastUpdateTime: Joi.bool().default(DEFAULT_OPTIONS.showLastUpdateTime),
|
||||
showLastUpdateAuthor: Joi.bool().default(
|
||||
|
|
|
@ -135,7 +135,7 @@ const ThemeConfigSchema = Joi.object({
|
|||
'themeConfig.navbar.links has been renamed as themeConfig.navbar.items',
|
||||
}),
|
||||
items: Joi.array().items(NavbarItemSchema),
|
||||
title: Joi.string().required(),
|
||||
title: Joi.string().allow('', null),
|
||||
logo: Joi.object({
|
||||
alt: Joi.string(),
|
||||
src: Joi.string().required(),
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
import {DocusaurusConfig} from '@docusaurus/types';
|
||||
import Joi from '@hapi/joi';
|
||||
import {CONFIG_FILE_NAME} from '../constants';
|
||||
import Joi from '@hapi/joi';
|
||||
|
||||
export const DEFAULT_CONFIG: Pick<
|
||||
DocusaurusConfig,
|
||||
|
@ -66,14 +66,14 @@ const ConfigSchema = Joi.object({
|
|||
src: Joi.string().required(),
|
||||
async: Joi.bool(),
|
||||
defer: Joi.bool(),
|
||||
}).oxor('async', 'defer'),
|
||||
}),
|
||||
),
|
||||
stylesheets: Joi.array().items(
|
||||
Joi.string(),
|
||||
Joi.object({
|
||||
href: Joi.string().uri().required(),
|
||||
href: Joi.string().required(),
|
||||
type: Joi.string().required(),
|
||||
}),
|
||||
}).unknown(),
|
||||
),
|
||||
tagline: Joi.string(),
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue