mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +02:00
* fix: add docs tag validation to solve #5478 fix: add docs tag validation to solve #5478 * Update docFrontMatter.ts * Update docs-create-doc.mdx * improve tag validation error messages + tests * improve tags doc * fix test Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
812327155b
commit
194f429c1f
5 changed files with 46 additions and 5 deletions
|
@ -61,12 +61,22 @@ export const PathnameSchema = Joi.string()
|
|||
'{{#label}} is not a valid pathname. Pathname should start with slash and not contain any domain or query string.',
|
||||
);
|
||||
|
||||
export const FrontMatterTagsSchema = JoiFrontMatter.array().items(
|
||||
JoiFrontMatter.alternatives().try(
|
||||
const FrontMatterTagSchema = JoiFrontMatter.alternatives()
|
||||
.try(
|
||||
JoiFrontMatter.string().required(),
|
||||
JoiFrontMatter.object<Tag>({
|
||||
label: JoiFrontMatter.string().required(),
|
||||
permalink: JoiFrontMatter.string().required(),
|
||||
}).required(),
|
||||
),
|
||||
);
|
||||
)
|
||||
.messages({
|
||||
'alternatives.match': '{{#label}} does not look like a valid tag',
|
||||
'alternatives.types': '{{#label}} does not look like a valid tag',
|
||||
});
|
||||
|
||||
export const FrontMatterTagsSchema = JoiFrontMatter.array()
|
||||
.items(FrontMatterTagSchema)
|
||||
.messages({
|
||||
'array.base':
|
||||
'{{#label}} does not look like a valid FrontMatter Yaml array.',
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue