mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-13 16:23:34 +02:00
refactor: unify how validateOptions is handled (#6961)
* refactor: unify how validateOptions is handled * fix types * fix again
This commit is contained in:
parent
44107fb879
commit
6e2eb44964
43 changed files with 542 additions and 540 deletions
27
packages/docusaurus-plugin-content-pages/src/frontMatter.ts
Normal file
27
packages/docusaurus-plugin-content-pages/src/frontMatter.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {
|
||||
Joi,
|
||||
validateFrontMatter,
|
||||
FrontMatterTOCHeadingLevels,
|
||||
} from '@docusaurus/utils-validation';
|
||||
import type {FrontMatter} from '@docusaurus/plugin-content-pages';
|
||||
|
||||
const PageFrontMatterSchema = Joi.object<FrontMatter>({
|
||||
title: Joi.string(),
|
||||
description: Joi.string(),
|
||||
wrapperClassName: Joi.string(),
|
||||
hide_table_of_contents: Joi.boolean(),
|
||||
...FrontMatterTOCHeadingLevels,
|
||||
});
|
||||
|
||||
export function validatePageFrontMatter(
|
||||
frontMatter: Record<string, unknown>,
|
||||
): FrontMatter {
|
||||
return validateFrontMatter(frontMatter, PageFrontMatterSchema);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue