refactor: unify how MDX content types are represented (#7145)

* refactor: unify how MDX content types are represented

* fix

* fix again
This commit is contained in:
Joshua Chen 2022-04-10 19:19:44 +08:00 committed by GitHub
parent b50def3ac0
commit 7a61eed3dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 33 deletions

View file

@ -6,6 +6,7 @@
*/
import type {Plugin} from 'unified';
import type {TOCItem} from '@docusaurus/types';
export type MDXPlugin =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@ -16,3 +17,21 @@ export type MDXOptions = {
beforeDefaultRemarkPlugins: MDXPlugin[];
beforeDefaultRehypePlugins: MDXPlugin[];
};
export type LoadedMDXContent<FrontMatter, Metadata, Assets = undefined> = {
/** As verbatim declared in the MDX document. */
readonly frontMatter: FrontMatter;
/** As provided by the content plugin. */
readonly metadata: Metadata;
/** A list of TOC items (headings). */
readonly toc: readonly TOCItem[];
/** First h1 title before any content. */
readonly contentTitle: string | undefined;
/**
* Usually image assets that may be collocated like `./img/thumbnail.png`.
* The loader would also bundle these assets and the client should use these
* in priority.
*/
readonly assets: Assets;
(): JSX.Element;
};