// This file is based on `DocItem` upstream, but since we aren't using markdown, // we had to duplicate it. Keep this file in sync as much as possible! // https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-theme-classic/src/theme/DocItem/index.tsx import type { PropNavigation } from '@docusaurus/plugin-content-docs'; import { ThemeClassNames, useWindowSize } from '@docusaurus/theme-common'; import DocBreadcrumbs from '@theme/DocBreadcrumbs'; import type { Props as DocItemProps } from '@theme/DocItem'; import DocPaginator from '@theme/DocPaginator'; import DocVersionBadge from '@theme/DocVersionBadge'; import Heading from '@theme/Heading'; import MDXContent from '@theme/MDXContent'; import TOC from '@theme/TOC'; import TOCCollapsible from '@theme/TOCCollapsible'; import { useBreadcrumbs } from '../hooks/useBreadcrumbs'; import type { TOCItem } from '../types'; import ApiOptionsLayout from './ApiOptionsLayout' import { Footer } from './Footer'; import { VersionBanner } from './VersionBanner'; export interface ApiItemLayoutProps extends Pick { children: React.ReactNode; heading: React.ReactNode; toc: readonly TOCItem[]; pageMetadata?: React.ReactNode; pagingMetadata?: PropNavigation; } export default function ApiItemLayout({ children, heading, pageMetadata, pagingMetadata, toc, }: ApiItemLayoutProps) { const windowSize = useWindowSize(); const breadcrumbs = useBreadcrumbs(); // Table of contents const canRenderTOC = toc.length > 0; const renderTocDesktop = canRenderTOC && (windowSize === 'desktop' || windowSize === 'ssr'); return ( <> {pageMetadata}
{breadcrumbs && } {canRenderTOC && ( <> {!renderTocDesktop && } )}
{heading}
{children}
{pagingMetadata && }
{renderTocDesktop && (
)}
); }