feat(content-pages): front matter validation, include front matter in metadata (#6400)

This commit is contained in:
Joshua Chen 2022-01-19 20:44:58 +08:00 committed by GitHub
parent e5801e49f6
commit fdf59f30f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 103 additions and 37 deletions

View file

@ -19,22 +19,45 @@ declare module '@docusaurus/plugin-content-pages' {
};
export type Options = Partial<PluginOptions>;
export type FrontMatter = {
readonly title?: string;
readonly description?: string;
readonly wrapperClassName?: string;
readonly hide_table_of_contents?: string;
readonly toc_min_heading_level?: number;
readonly toc_max_heading_level?: number;
};
export type JSXPageMetadata = {
type: 'jsx';
permalink: string;
source: string;
};
export type MDXPageMetadata = {
type: 'mdx';
permalink: string;
source: string;
frontMatter: FrontMatter & Record<string, unknown>;
title?: string;
description?: string;
};
export type Metadata = JSXPageMetadata | MDXPageMetadata;
}
declare module '@theme/MDXPage' {
import type {TOCItem} from '@docusaurus/types';
import type {
MDXPageMetadata,
FrontMatter,
} from '@docusaurus/plugin-content-pages';
export interface Props {
readonly content: {
readonly frontMatter: {
readonly title: string;
readonly description: string;
readonly wrapperClassName?: string;
readonly hide_table_of_contents?: string;
readonly toc_min_heading_level?: number;
readonly toc_max_heading_level?: number;
};
readonly metadata: {readonly permalink: string};
readonly frontMatter: FrontMatter;
readonly metadata: MDXPageMetadata;
readonly toc: readonly TOCItem[];
(): JSX.Element;
};