docusaurus/packages/docusaurus-plugin-content-docs/src/plugin-content-docs.d.ts

209 lines
6.0 KiB
TypeScript
Raw Normal View History

/**
* 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.
*/
declare module '@docusaurus/plugin-content-docs-types' {
feat(v2): allow any type of `NavbarItem` to be passed in a navbar dropdown (#5072) * Initial work Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * More elegant `eslint-disable` Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Fix typing Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Allow doc links in dropdown Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Allow more dropdowns to use linklike items Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Finalize Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Dogfood Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Disallow nested dropdowns Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Better typing Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Complete type fix Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Use flatmap Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Patch Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Test Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Try fix Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Style change Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Revert (to test) Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Hmmm Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * I know what's wrong Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Does this work? Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Nope Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Wrong class name Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Pass prop to render dropdown item differently Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * This looks better Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Tests passed Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Separate dropdown from default Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Pourquois? Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Better prop typing Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Make code simpler Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * There's some extra className Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Test Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * More test Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * A-ha! Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Test again? * Add backward compatibility Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Incorporate my type fix Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Resolve conflict Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * minor refactor * minor refactors * allow usage of ES2019 in browser code * revert NavLink rename Co-authored-by: slorber <lorber.sebastien@gmail.com>
2021-07-14 12:19:08 -04:00
type VersionBanner = import('./types').VersionBanner;
type GlobalDataVersion = import('./types').GlobalVersion;
type GlobalDataDoc = import('./types').GlobalDoc;
type VersionTag = import('./types').VersionTag;
export type {GlobalDataVersion, GlobalDataDoc};
export type PropVersionMetadata = {
pluginId: string;
version: string;
label: string;
banner: VersionBanner;
isLast: boolean;
docsSidebars: PropSidebars;
};
type PropsSidebarItemBase = {
customProps?: Record<string, unknown>;
};
export type PropSidebarItemLink = PropsSidebarItemBase & {
type: 'link';
href: string;
label: string;
};
export type PropSidebarItemCategory = PropsSidebarItemBase & {
type: 'category';
label: string;
items: PropSidebarItem[];
collapsed: boolean;
collapsible: boolean;
};
export type PropSidebarItem = PropSidebarItemLink | PropSidebarItemCategory;
export type PropSidebars = {
[sidebarId: string]: PropSidebarItem[];
};
export type PropTagDocListDoc = {
id: string;
title: string;
description: string;
permalink: string;
};
export type PropTagDocList = {
allTagsPath: string;
name: string; // normalized name/label of the tag
permalink: string; // pathname of the tag
docs: PropTagDocListDoc[];
};
export type PropTagsListPage = {
tags: {
name: string;
permalink: string;
count: number;
}[];
};
}
declare module '@theme/DocItem' {
import type {TOCItem} from '@docusaurus/types';
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs-types';
export type DocumentRoute = {
readonly component: () => JSX.Element;
readonly exact: boolean;
readonly path: string;
feat(v2): redesign mobile UX: inline TOC + doc sidebar in main menu (#4273) * feat(v2): mobile TOC * Bug fixes and various improvements * Redesign * extract TOCCollapsible component * TS improvements * Assign sidebar name directly to the doc route => no need for either permalinkToSidebar or GlobalData * revert changes to useWindowSize, fix FOUC issues * extract DocSidebarDesktop component * remove now useless menu infima classes * TOCHeadings => rename + remove unused onClick prop * Extract DocSidebarItem * minor renaming * replace GlobalData usage by a React teleport system to render in the navbar mobile sidebar menu directly from the DocPage component * useWindowSize => simulate SSR size in dev to make FOUC issues more obvious * fix remaining sidebar layout shift * update docs snapshots * remove unused code translations * remove unused code translations * fix minor update-code-translations bug * Add more build-size paths to watch * Restyle back button * Add missing`menu` class * extract useShallowMemoizedObject * fix routes tests + better routes formatting * use Translate api for labels * use Translate api for labels * Update translations * Improve dark mode support for back button * Merge branch 'master' into lex111/inline-color-code # Conflicts: # packages/core/dist/css/default-dark/default-dark-rtl.min.css # packages/core/dist/css/default-dark/default-dark.min.css # packages/core/dist/css/default/default-rtl.min.css # packages/core/dist/css/default/default.min.css * replace useCollapse by new useCollapsible * Cleanup and use clean-btn for TOCCollapsible button * Make TOC links clickable over full width * Cleanup * fix uncollapsible sidebar that can be collapsed + create <Collapsible> component * dependency array typo * rollback sidebars community commit typo Co-authored-by: slorber <lorber.sebastien@gmail.com>
2021-07-09 10:50:38 -04:00
readonly sidebar?: string;
};
export type FrontMatter = {
readonly id: string;
readonly title: string;
readonly image?: string;
readonly keywords?: readonly string[];
/* eslint-disable camelcase */
readonly hide_title?: boolean;
readonly hide_table_of_contents?: boolean;
/* eslint-enable camelcase */
};
export type Metadata = {
readonly description?: string;
readonly title?: string;
readonly permalink?: string;
readonly editUrl?: string;
readonly lastUpdatedAt?: number;
readonly formattedLastUpdatedAt?: string;
readonly lastUpdatedBy?: string;
readonly version?: string;
readonly previous?: {readonly permalink: string; readonly title: string};
readonly next?: {readonly permalink: string; readonly title: string};
readonly tags: readonly {
readonly label: string;
readonly permalink: string;
}[];
};
export type Props = {
readonly route: DocumentRoute;
readonly versionMetadata: PropVersionMetadata;
readonly content: {
readonly frontMatter: FrontMatter;
readonly metadata: Metadata;
readonly toc: readonly TOCItem[];
readonly contentTitle: string | undefined;
(): JSX.Element;
};
};
const DocItem: (props: Props) => JSX.Element;
export default DocItem;
}
declare module '@theme/DocItemFooter' {
import type {Props} from '@theme/DocItem';
export default function DocItemFooter(props: Props): JSX.Element;
}
declare module '@theme/DocTagsListPage' {
import type {PropTagsListPage} from '@docusaurus/plugin-content-docs-types';
export type Props = PropTagsListPage;
export default function DocItemFooter(props: Props): JSX.Element;
}
declare module '@theme/DocVersionBanner' {
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs-types';
export type Props = {
readonly versionMetadata: PropVersionMetadata;
};
const DocVersionBanner: (props: Props) => JSX.Element;
export default DocVersionBanner;
}
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: DocumentRoute[];
};
};
const DocPage: (props: Props) => JSX.Element;
export default DocPage;
}
declare module '@theme/Seo' {
export type Props = {
readonly title?: string;
readonly description?: string;
readonly keywords?: readonly string[] | string;
readonly image?: string;
readonly children?: ReactNode;
};
const Seo: (props: Props) => JSX.Element;
export default Seo;
}
declare module '@theme/hooks/useDocs' {
type GlobalPluginData = import('./types').GlobalPluginData;
type GlobalVersion = import('./types').GlobalVersion;
type ActivePlugin = import('./client/docsClientUtils').ActivePlugin;
type ActiveDocContext = import('./client/docsClientUtils').ActiveDocContext;
type DocVersionSuggestions = import('./client/docsClientUtils').DocVersionSuggestions;
export type {GlobalPluginData, GlobalVersion};
export const useAllDocsData: () => Record<string, GlobalPluginData>;
export const useDocsData: (pluginId?: string) => GlobalPluginData;
export const useActivePlugin: (
options: GetActivePluginOptions = {},
) => ActivePlugin | undefined;
export const useActivePluginAndVersion: (
options: GetActivePluginOptions = {},
) =>
| {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
| undefined;
export const useVersions: (pluginId?: string) => GlobalVersion[];
export const useLatestVersion: (pluginId?: string) => GlobalVersion;
export const useActiveVersion: (
pluginId?: string,
) => GlobalVersion | undefined;
export const useActiveDocContext: (pluginId?: string) => ActiveDocContext;
export const useDocVersionSuggestions: (
pluginId?: string,
) => DocVersionSuggestions;
}