mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-23 11:38:48 +02:00
feat(content-pages): front matter validation, include front matter in metadata (#6400)
This commit is contained in:
parent
e5801e49f6
commit
fdf59f30f0
7 changed files with 103 additions and 37 deletions
|
@ -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.string(),
|
||||
...FrontMatterTOCHeadingLevels,
|
||||
});
|
||||
|
||||
export function validatePageFrontMatter(
|
||||
frontMatter: Record<string, unknown>,
|
||||
): FrontMatter {
|
||||
return validateFrontMatter(frontMatter, PageFrontMatterSchema);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue