mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-05 04:12:53 +02:00
feat(v2): Provide docs plugin typing (#3328)
This commit is contained in:
parent
b86806460c
commit
d299b99631
10 changed files with 125 additions and 35 deletions
101
packages/docusaurus-plugin-content-docs/src/plugin-content-docs.d.ts
vendored
Normal file
101
packages/docusaurus-plugin-content-docs/src/plugin-content-docs.d.ts
vendored
Normal file
|
@ -0,0 +1,101 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
declare module '@docusaurus/plugin-content-docs-types' {
|
||||
export type VersionName = string;
|
||||
|
||||
export type PermalinkToSidebar = {
|
||||
[permalink: string]: string;
|
||||
};
|
||||
|
||||
export type PropVersionMetadata = {
|
||||
version: VersionName;
|
||||
docsSidebars: PropSidebars;
|
||||
permalinkToSidebar: PermalinkToSidebar;
|
||||
};
|
||||
|
||||
export type PropSidebarItemLink = {
|
||||
type: 'link';
|
||||
href: string;
|
||||
label: string;
|
||||
};
|
||||
|
||||
export type PropSidebarItemCategory = {
|
||||
type: 'category';
|
||||
label: string;
|
||||
items: PropSidebarItem[];
|
||||
collapsed?: boolean;
|
||||
};
|
||||
|
||||
export type PropSidebarItem = PropSidebarItemLink | PropSidebarItemCategory;
|
||||
|
||||
export type PropSidebars = {
|
||||
[sidebarId: string]: PropSidebarItem[];
|
||||
};
|
||||
}
|
||||
|
||||
declare module '@theme/DocItem' {
|
||||
import type {MarkdownRightTableOfContents} from '@docusaurus/types';
|
||||
|
||||
export type DocumentRoute = {
|
||||
readonly component: () => JSX.Element;
|
||||
readonly exact: boolean;
|
||||
readonly path: string;
|
||||
};
|
||||
|
||||
export type FrontMatter = {
|
||||
readonly id: string;
|
||||
readonly title: string;
|
||||
readonly image?: string;
|
||||
readonly keywords?: readonly string[];
|
||||
readonly hide_title?: boolean;
|
||||
readonly hide_table_of_contents?: boolean;
|
||||
};
|
||||
|
||||
export type Metadata = {
|
||||
readonly description?: string;
|
||||
readonly title?: string;
|
||||
readonly permalink?: string;
|
||||
readonly editUrl?: string;
|
||||
readonly lastUpdatedAt?: number;
|
||||
readonly lastUpdatedBy?: string;
|
||||
readonly version?: string;
|
||||
};
|
||||
|
||||
export type Props = {
|
||||
readonly route: DocumentRoute;
|
||||
readonly content: {
|
||||
readonly frontMatter: FrontMatter;
|
||||
readonly metadata: Metadata;
|
||||
readonly rightToc: MarkdownRightTableOfContents;
|
||||
(): JSX.Element;
|
||||
};
|
||||
};
|
||||
|
||||
const DocItem: (props: Props) => JSX.Element;
|
||||
export default DocItem;
|
||||
}
|
||||
|
||||
declare module '@theme/DocPage' {
|
||||
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs-types';
|
||||
import type {DocumentRoute} from '@theme/DocItem';
|
||||
|
||||
export type Props = {
|
||||
readonly location: {readonly pathname: string};
|
||||
readonly versionMetadata: PropVersionMetadata;
|
||||
readonly route: {
|
||||
readonly path: string;
|
||||
readonly component: () => JSX.Element;
|
||||
readonly routes: readonly DocumentRoute[];
|
||||
};
|
||||
};
|
||||
|
||||
const DocPage: (props: Props) => JSX.Element;
|
||||
export default DocPage;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue