|
1 | 1 | import React from 'react';
|
2 |
| -import clsx from 'clsx'; |
3 |
| -import { useWindowSize } from '@docusaurus/theme-common'; |
4 |
| -import { useDoc } from '@docusaurus/theme-common/internal'; |
5 |
| -import DocItemPaginator from '@theme/DocItem/Paginator'; |
6 |
| -import DocVersionBanner from '@theme/DocVersionBanner'; |
7 |
| -import DocVersionBadge from '@theme/DocVersionBadge'; |
8 |
| -import DocItemFooter from '@theme/DocItem/Footer'; |
9 |
| -import DocItemTOCMobile from '@theme/DocItem/TOC/Mobile'; |
10 |
| -import DocItemTOCDesktop from '@theme/DocItem/TOC/Desktop'; |
11 |
| -import DocItemContent from '@theme/DocItem/Content'; |
12 |
| -import DocBreadcrumbs from '@theme/DocBreadcrumbs'; |
13 |
| -import Unlisted from '@theme/Unlisted'; |
14 |
| -import type { Props } from '@theme/DocItem/Layout'; |
| 2 | +import Layout from '@theme-original/DocItem/Layout'; |
| 3 | +import type LayoutType from '@theme/DocItem/Layout'; |
| 4 | +import type { WrapperProps } from '@docusaurus/types'; |
| 5 | +// highlight-add-line |
| 6 | +import Comment from '@site/src/components/Comment'; |
15 | 7 |
|
16 |
| -import styles from './styles.module.css'; |
17 |
| -import Comment from '../../../components/Comment'; |
| 8 | +type Props = WrapperProps<typeof LayoutType>; |
18 | 9 |
|
19 |
| -/** |
20 |
| - * Decide if the toc should be rendered, on mobile or desktop viewports |
21 |
| - */ |
22 |
| -function useDocTOC() { |
23 |
| - const { frontMatter, toc } = useDoc(); |
24 |
| - const windowSize = useWindowSize(); |
25 |
| - |
26 |
| - const hidden = frontMatter.hide_table_of_contents; |
27 |
| - const canRender = !hidden && toc.length > 0; |
28 |
| - |
29 |
| - const mobile = canRender ? <DocItemTOCMobile /> : undefined; |
30 |
| - |
31 |
| - const desktop = |
32 |
| - canRender && (windowSize === 'desktop' || windowSize === 'ssr') ? ( |
33 |
| - <DocItemTOCDesktop /> |
34 |
| - ) : undefined; |
35 |
| - |
36 |
| - return { |
37 |
| - hidden, |
38 |
| - mobile, |
39 |
| - desktop, |
40 |
| - }; |
41 |
| -} |
42 |
| - |
43 |
| -export default function DocItemLayout({ children }: Props): JSX.Element { |
44 |
| - const docTOC = useDocTOC(); |
45 |
| - const { frontMatter } = useDoc(); |
46 |
| - const { hide_comment: hideComment } = frontMatter; |
47 |
| - const { |
48 |
| - metadata: { unlisted }, |
49 |
| - } = useDoc(); |
| 10 | +export default function LayoutWrapper(props: Props): JSX.Element { |
50 | 11 | return (
|
51 |
| - <div className="row"> |
52 |
| - <div className={clsx('col', !docTOC.hidden && styles.docItemCol)}> |
53 |
| - {unlisted && <Unlisted />} |
54 |
| - <DocVersionBanner /> |
55 |
| - <div className={styles.docItemContainer}> |
56 |
| - <article> |
57 |
| - <DocBreadcrumbs /> |
58 |
| - <DocVersionBadge /> |
59 |
| - {docTOC.mobile} |
60 |
| - <DocItemContent>{children}</DocItemContent> |
61 |
| - <DocItemFooter /> |
62 |
| - </article> |
63 |
| - <DocItemPaginator /> |
64 |
| - </div> |
65 |
| - {!hideComment && <Comment />} |
66 |
| - </div> |
67 |
| - {docTOC.desktop && <div className="col col--3">{docTOC.desktop}</div>} |
68 |
| - </div> |
| 12 | + <> |
| 13 | + <Layout {...props} /> |
| 14 | + {/* highlight-add-line */} |
| 15 | + <Comment /> |
| 16 | + </> |
69 | 17 | );
|
70 | 18 | }
|
0 commit comments