@docusaurus/theme-classic 0.0.0-4238 → 0.0.0-4243
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +4 -1
- package/lib/theme/DocCard/index.js +84 -0
- package/lib/theme/DocCard/styles.module.css +43 -0
- package/lib/theme/DocCardList/index.js +28 -0
- package/lib/theme/DocCategoryGeneratedIndexPage/index.js +57 -0
- package/lib/theme/DocCategoryGeneratedIndexPage/styles.module.css +18 -0
- package/lib/theme/DocItem/index.js +6 -7
- package/lib/theme/DocPage/index.js +16 -9
- package/lib/theme/DocPaginator/index.js +6 -7
- package/lib/theme/DocSidebar/index.js +10 -1
- package/lib/theme/DocSidebarItem/index.js +64 -30
- package/lib/theme/DocSidebarItem/styles.module.css +4 -0
- package/lib/theme/DocVersionBadge/index.js +34 -0
- package/lib/theme/DocVersionBanner/index.js +8 -8
- package/lib/theme-classic.d.ts +5 -4
- package/lib-next/index.js +5 -1
- package/lib-next/theme/DocCard/index.js +80 -0
- package/lib-next/theme/DocCard/styles.module.css +43 -0
- package/lib-next/theme/DocCardList/index.js +19 -0
- package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +49 -0
- package/lib-next/theme/DocCategoryGeneratedIndexPage/styles.module.css +18 -0
- package/lib-next/theme/DocItem/index.js +5 -12
- package/lib-next/theme/DocPage/index.js +31 -14
- package/lib-next/theme/DocPaginator/index.js +7 -11
- package/lib-next/theme/DocSidebar/index.js +10 -1
- package/lib-next/theme/DocSidebarItem/index.js +78 -37
- package/lib-next/theme/DocSidebarItem/styles.module.css +4 -0
- package/lib-next/theme/DocVersionBadge/index.js +27 -0
- package/lib-next/theme/DocVersionBanner/index.js +12 -5
- package/lib-next/theme-classic.d.ts +5 -4
- package/package.json +13 -13
- package/src/index.ts +9 -4
- package/src/theme/DocCard/index.tsx +100 -0
- package/src/theme/DocCard/styles.module.css +43 -0
- package/src/theme/DocCardList/index.tsx +27 -0
- package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +53 -0
- package/src/theme/DocCategoryGeneratedIndexPage/styles.module.css +18 -0
- package/src/theme/DocItem/index.tsx +5 -12
- package/src/theme/DocPage/index.tsx +28 -12
- package/src/theme/DocPaginator/index.tsx +9 -13
- package/src/theme/DocSidebar/index.tsx +9 -1
- package/src/theme/DocSidebarItem/index.tsx +77 -38
- package/src/theme/DocSidebarItem/styles.module.css +4 -0
- package/src/theme/DocVersionBadge/index.tsx +30 -0
- package/src/theme/DocVersionBanner/index.tsx +23 -7
- package/src/theme-classic.d.ts +5 -4
- package/src/translations.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4243",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -23,21 +23,21 @@
|
|
|
23
23
|
"update-code-translations": "node -e 'require(\"./update-code-translations.js\").run()'"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@docusaurus/core": "0.0.0-
|
|
27
|
-
"@docusaurus/plugin-content-blog": "0.0.0-
|
|
28
|
-
"@docusaurus/plugin-content-docs": "0.0.0-
|
|
29
|
-
"@docusaurus/plugin-content-pages": "0.0.0-
|
|
30
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
31
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
32
|
-
"@docusaurus/utils": "0.0.0-
|
|
33
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
26
|
+
"@docusaurus/core": "0.0.0-4243",
|
|
27
|
+
"@docusaurus/plugin-content-blog": "0.0.0-4243",
|
|
28
|
+
"@docusaurus/plugin-content-docs": "0.0.0-4243",
|
|
29
|
+
"@docusaurus/plugin-content-pages": "0.0.0-4243",
|
|
30
|
+
"@docusaurus/theme-common": "0.0.0-4243",
|
|
31
|
+
"@docusaurus/theme-translations": "0.0.0-4243",
|
|
32
|
+
"@docusaurus/utils": "0.0.0-4243",
|
|
33
|
+
"@docusaurus/utils-validation": "0.0.0-4243",
|
|
34
34
|
"@mdx-js/mdx": "^1.6.21",
|
|
35
35
|
"@mdx-js/react": "^1.6.21",
|
|
36
36
|
"chalk": "^4.1.2",
|
|
37
37
|
"clsx": "^1.1.1",
|
|
38
38
|
"copy-text-to-clipboard": "^3.0.1",
|
|
39
39
|
"globby": "^11.0.2",
|
|
40
|
-
"infima": "0.2.0-alpha.
|
|
40
|
+
"infima": "0.2.0-alpha.36",
|
|
41
41
|
"lodash": "^4.17.20",
|
|
42
42
|
"postcss": "^8.3.7",
|
|
43
43
|
"prism-react-renderer": "^1.2.1",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"rtlcss": "^3.3.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
50
|
-
"@docusaurus/types": "0.0.0-
|
|
49
|
+
"@docusaurus/module-type-aliases": "0.0.0-4243",
|
|
50
|
+
"@docusaurus/types": "0.0.0-4243",
|
|
51
51
|
"@types/mdx-js__react": "^1.5.4",
|
|
52
52
|
"@types/parse-numeric-range": "^0.0.1",
|
|
53
53
|
"@types/rtlcss": "^3.1.1",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=14"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "9ff41c223c3422e3483bc1049ee9ec703d11e0cd"
|
|
66
66
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {DocusaurusContext, Plugin} from '@docusaurus/types';
|
|
8
|
+
import {DocusaurusContext, Plugin, PostCssOptions} from '@docusaurus/types';
|
|
9
9
|
import type {ThemeConfig} from '@docusaurus/theme-common';
|
|
10
10
|
import {getTranslationFiles, translateThemeConfig} from './translations';
|
|
11
11
|
import path from 'path';
|
|
12
12
|
import {createRequire} from 'module';
|
|
13
|
-
import type {
|
|
13
|
+
import type {Plugin as PostCssPlugin} from 'postcss';
|
|
14
14
|
import rtlcss from 'rtlcss';
|
|
15
15
|
import {readDefaultCodeTranslationMessages} from '@docusaurus/theme-translations';
|
|
16
16
|
|
|
@@ -132,7 +132,12 @@ export default function docusaurusThemeClassic(
|
|
|
132
132
|
},
|
|
133
133
|
|
|
134
134
|
getTranslationFiles: async () => getTranslationFiles({themeConfig}),
|
|
135
|
-
|
|
135
|
+
|
|
136
|
+
translateThemeConfig: (params) =>
|
|
137
|
+
translateThemeConfig({
|
|
138
|
+
themeConfig: params.themeConfig as ThemeConfig,
|
|
139
|
+
translationFiles: params.translationFiles,
|
|
140
|
+
}),
|
|
136
141
|
|
|
137
142
|
getDefaultCodeTranslationMessages() {
|
|
138
143
|
return readDefaultCodeTranslationMessages({
|
|
@@ -178,7 +183,7 @@ export default function docusaurusThemeClassic(
|
|
|
178
183
|
};
|
|
179
184
|
},
|
|
180
185
|
|
|
181
|
-
configurePostCss(postCssOptions:
|
|
186
|
+
configurePostCss(postCssOptions: PostCssOptions) {
|
|
182
187
|
if (direction === 'rtl') {
|
|
183
188
|
const resolvedInfimaFile = require.resolve(getInfimaCSSFile(direction));
|
|
184
189
|
const plugin: PostCssPlugin = {
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React, {ReactNode} from 'react';
|
|
9
|
+
import Link from '@docusaurus/Link';
|
|
10
|
+
import {
|
|
11
|
+
PropSidebarItemCategory,
|
|
12
|
+
PropSidebarItemLink,
|
|
13
|
+
} from '@docusaurus/plugin-content-docs';
|
|
14
|
+
import type {Props} from '@theme/DocCard';
|
|
15
|
+
import {findFirstCategoryLink, useDocById} from '@docusaurus/theme-common';
|
|
16
|
+
import clsx from 'clsx';
|
|
17
|
+
import styles from './styles.module.css';
|
|
18
|
+
import isInternalUrl from '@docusaurus/isInternalUrl';
|
|
19
|
+
|
|
20
|
+
function CardContainer({
|
|
21
|
+
href,
|
|
22
|
+
children,
|
|
23
|
+
}: {
|
|
24
|
+
href?: string;
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
}): JSX.Element {
|
|
27
|
+
const className = clsx(
|
|
28
|
+
'card margin-bottom--lg padding--lg',
|
|
29
|
+
styles.cardContainer,
|
|
30
|
+
href && styles.cardContainerLink,
|
|
31
|
+
);
|
|
32
|
+
return href ? (
|
|
33
|
+
<Link href={href} className={className}>
|
|
34
|
+
{children}
|
|
35
|
+
</Link>
|
|
36
|
+
) : (
|
|
37
|
+
<div className={className}>{children}</div>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function CardLayout({
|
|
42
|
+
href,
|
|
43
|
+
icon,
|
|
44
|
+
title,
|
|
45
|
+
description,
|
|
46
|
+
}: {
|
|
47
|
+
href?: string;
|
|
48
|
+
icon: ReactNode;
|
|
49
|
+
title: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
}): JSX.Element {
|
|
52
|
+
return (
|
|
53
|
+
<CardContainer href={href}>
|
|
54
|
+
<h2 className={clsx('text--truncate', styles.cardTitle)} title={title}>
|
|
55
|
+
{icon} {title}
|
|
56
|
+
</h2>
|
|
57
|
+
<div
|
|
58
|
+
className={clsx('text--truncate', styles.cardDescription)}
|
|
59
|
+
title={description}>
|
|
60
|
+
{description}
|
|
61
|
+
</div>
|
|
62
|
+
</CardContainer>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function CardCategory({item}: {item: PropSidebarItemCategory}): JSX.Element {
|
|
67
|
+
const href = findFirstCategoryLink(item);
|
|
68
|
+
return (
|
|
69
|
+
<CardLayout
|
|
70
|
+
href={href}
|
|
71
|
+
icon="🗃️"
|
|
72
|
+
title={item.label}
|
|
73
|
+
description={`${item.items.length} items`}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function CardLink({item}: {item: PropSidebarItemLink}): JSX.Element {
|
|
79
|
+
const icon = isInternalUrl(item.href) ? '📄️' : '🔗';
|
|
80
|
+
const doc = useDocById(item.docId ?? undefined);
|
|
81
|
+
return (
|
|
82
|
+
<CardLayout
|
|
83
|
+
href={item.href}
|
|
84
|
+
icon={icon}
|
|
85
|
+
title={item.label}
|
|
86
|
+
description={doc?.description}
|
|
87
|
+
/>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default function DocCard({item}: Props): JSX.Element {
|
|
92
|
+
switch (item.type) {
|
|
93
|
+
case 'link':
|
|
94
|
+
return <CardLink item={item} />;
|
|
95
|
+
case 'category':
|
|
96
|
+
return <CardCategory item={item} />;
|
|
97
|
+
default:
|
|
98
|
+
throw new Error(`unknown item type ${JSON.stringify(item)}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
.cardContainer {
|
|
9
|
+
height: 8rem;
|
|
10
|
+
|
|
11
|
+
color: var(--ifm-color-emphasis-800);
|
|
12
|
+
--ifm-link-color: var(--ifm-color-emphasis-800);
|
|
13
|
+
--ifm-link-hover-color: var(--ifm-color-emphasis-800);
|
|
14
|
+
--ifm-link-hover-decoration: none;
|
|
15
|
+
|
|
16
|
+
/* box-shadow: var(--ifm-global-shadow-lw); */
|
|
17
|
+
box-shadow: 0 1.5px 3px 0 rgba(0, 0, 0, 0.15);
|
|
18
|
+
border: 1px solid var(--ifm-color-emphasis-200);
|
|
19
|
+
transition: box-shadow var(--ifm-transition-fast) ease,
|
|
20
|
+
background-color var(--ifm-transition-fast) ease;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.cardContainer.cardContainerLink:hover {
|
|
24
|
+
/* box-shadow: var(--ifm-global-shadow-md); */
|
|
25
|
+
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
|
|
26
|
+
}
|
|
27
|
+
html[data-theme='dark'] .cardContainer.cardContainerLink:hover {
|
|
28
|
+
--ifm-card-background-color: #2d2d2d; /* original, non-hovered color is #242526 */
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.cardContainer:not(.cardContainerLink) {
|
|
32
|
+
cursor: not-allowed;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.cardTitle {
|
|
36
|
+
font-size: 1.2rem;
|
|
37
|
+
min-height: 1.2rem;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.cardDescription {
|
|
41
|
+
font-size: 0.8rem;
|
|
42
|
+
min-height: 0.8rem;
|
|
43
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
import DocCard from '@theme/DocCard';
|
|
11
|
+
import {PropSidebarItem} from '@docusaurus/plugin-content-docs';
|
|
12
|
+
|
|
13
|
+
export default function DocCardList({
|
|
14
|
+
items,
|
|
15
|
+
}: {
|
|
16
|
+
items: PropSidebarItem[];
|
|
17
|
+
}): JSX.Element {
|
|
18
|
+
return (
|
|
19
|
+
<div className="row">
|
|
20
|
+
{items.map((item, index) => (
|
|
21
|
+
<article key={index} className="col col--6">
|
|
22
|
+
<DocCard item={item} />
|
|
23
|
+
</article>
|
|
24
|
+
))}
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
10
|
+
import type {Props} from '@theme/DocCategoryGeneratedIndexPage';
|
|
11
|
+
import DocCardList from '@theme/DocCardList';
|
|
12
|
+
import DocPaginator from '@theme/DocPaginator';
|
|
13
|
+
import Seo from '@theme/Seo';
|
|
14
|
+
import DocVersionBanner from '@theme/DocVersionBanner';
|
|
15
|
+
import DocVersionBadge from '@theme/DocVersionBadge';
|
|
16
|
+
import {MainHeading} from '@theme/Heading';
|
|
17
|
+
|
|
18
|
+
import styles from './styles.module.css';
|
|
19
|
+
|
|
20
|
+
export default function DocCategoryGeneratedIndexPage({
|
|
21
|
+
categoryGeneratedIndex,
|
|
22
|
+
}: Props): JSX.Element {
|
|
23
|
+
const category = useCurrentSidebarCategory();
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
<Seo
|
|
27
|
+
title={categoryGeneratedIndex.title}
|
|
28
|
+
description={categoryGeneratedIndex.description}
|
|
29
|
+
/>
|
|
30
|
+
<div className={styles.generatedIndexPage}>
|
|
31
|
+
<DocVersionBanner />
|
|
32
|
+
<DocVersionBadge />
|
|
33
|
+
<header>
|
|
34
|
+
<MainHeading className={styles.title}>
|
|
35
|
+
{categoryGeneratedIndex.title}
|
|
36
|
+
</MainHeading>
|
|
37
|
+
{categoryGeneratedIndex.description && (
|
|
38
|
+
<p>{categoryGeneratedIndex.description}</p>
|
|
39
|
+
)}
|
|
40
|
+
</header>
|
|
41
|
+
<main className="margin-top--lg">
|
|
42
|
+
<DocCardList items={category.items} />
|
|
43
|
+
</main>
|
|
44
|
+
<footer className="margin-top--lg">
|
|
45
|
+
<DocPaginator
|
|
46
|
+
previous={categoryGeneratedIndex.navigation.previous}
|
|
47
|
+
next={categoryGeneratedIndex.navigation.next}
|
|
48
|
+
/>
|
|
49
|
+
</footer>
|
|
50
|
+
</div>
|
|
51
|
+
</>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
@media (min-width: 997px) {
|
|
9
|
+
.generatedIndexPage {
|
|
10
|
+
max-width: 75% !important;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Duplicated from .markdown h1 */
|
|
15
|
+
.title {
|
|
16
|
+
--ifm-h1-font-size: 3rem;
|
|
17
|
+
margin-bottom: calc(1.25 * var(--ifm-leading));
|
|
18
|
+
}
|
|
@@ -10,6 +10,7 @@ import clsx from 'clsx';
|
|
|
10
10
|
import useWindowSize from '@theme/hooks/useWindowSize';
|
|
11
11
|
import DocPaginator from '@theme/DocPaginator';
|
|
12
12
|
import DocVersionBanner from '@theme/DocVersionBanner';
|
|
13
|
+
import DocVersionBadge from '@theme/DocVersionBadge';
|
|
13
14
|
import Seo from '@theme/Seo';
|
|
14
15
|
import type {Props} from '@theme/DocItem';
|
|
15
16
|
import DocItemFooter from '@theme/DocItemFooter';
|
|
@@ -20,7 +21,7 @@ import styles from './styles.module.css';
|
|
|
20
21
|
import {ThemeClassNames} from '@docusaurus/theme-common';
|
|
21
22
|
|
|
22
23
|
export default function DocItem(props: Props): JSX.Element {
|
|
23
|
-
const {content: DocContent
|
|
24
|
+
const {content: DocContent} = props;
|
|
24
25
|
const {metadata, frontMatter} = DocContent;
|
|
25
26
|
const {
|
|
26
27
|
image,
|
|
@@ -55,18 +56,10 @@ export default function DocItem(props: Props): JSX.Element {
|
|
|
55
56
|
className={clsx('col', {
|
|
56
57
|
[styles.docItemCol]: !hideTableOfContents,
|
|
57
58
|
})}>
|
|
58
|
-
<DocVersionBanner
|
|
59
|
+
<DocVersionBanner />
|
|
59
60
|
<div className={styles.docItemContainer}>
|
|
60
61
|
<article>
|
|
61
|
-
|
|
62
|
-
<span
|
|
63
|
-
className={clsx(
|
|
64
|
-
ThemeClassNames.docs.docVersionBadge,
|
|
65
|
-
'badge badge--secondary',
|
|
66
|
-
)}>
|
|
67
|
-
Version: {versionMetadata.label}
|
|
68
|
-
</span>
|
|
69
|
-
)}
|
|
62
|
+
<DocVersionBadge />
|
|
70
63
|
|
|
71
64
|
{canRenderTOC && (
|
|
72
65
|
<TOCCollapsible
|
|
@@ -95,7 +88,7 @@ export default function DocItem(props: Props): JSX.Element {
|
|
|
95
88
|
<DocItemFooter {...props} />
|
|
96
89
|
</article>
|
|
97
90
|
|
|
98
|
-
<DocPaginator metadata={metadata} />
|
|
91
|
+
<DocPaginator previous={metadata.previous} next={metadata.next} />
|
|
99
92
|
</div>
|
|
100
93
|
</div>
|
|
101
94
|
{renderTocDesktop && (
|
|
@@ -23,27 +23,30 @@ import {translate} from '@docusaurus/Translate';
|
|
|
23
23
|
|
|
24
24
|
import clsx from 'clsx';
|
|
25
25
|
import styles from './styles.module.css';
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
ThemeClassNames,
|
|
28
|
+
docVersionSearchTag,
|
|
29
|
+
DocsSidebarProvider,
|
|
30
|
+
useDocsSidebar,
|
|
31
|
+
DocsVersionProvider,
|
|
32
|
+
} from '@docusaurus/theme-common';
|
|
27
33
|
import Head from '@docusaurus/Head';
|
|
28
34
|
|
|
29
35
|
type DocPageContentProps = {
|
|
30
36
|
readonly currentDocRoute: DocumentRoute;
|
|
31
37
|
readonly versionMetadata: PropVersionMetadata;
|
|
32
38
|
readonly children: ReactNode;
|
|
39
|
+
readonly sidebarName: string | undefined;
|
|
33
40
|
};
|
|
34
41
|
|
|
35
42
|
function DocPageContent({
|
|
36
43
|
currentDocRoute,
|
|
37
44
|
versionMetadata,
|
|
38
45
|
children,
|
|
46
|
+
sidebarName,
|
|
39
47
|
}: DocPageContentProps): JSX.Element {
|
|
48
|
+
const sidebar = useDocsSidebar();
|
|
40
49
|
const {pluginId, version} = versionMetadata;
|
|
41
|
-
|
|
42
|
-
const sidebarName = currentDocRoute.sidebar;
|
|
43
|
-
const sidebar = sidebarName
|
|
44
|
-
? versionMetadata.docsSidebars[sidebarName]
|
|
45
|
-
: undefined;
|
|
46
|
-
|
|
47
50
|
const [hiddenSidebarContainer, setHiddenSidebarContainer] = useState(false);
|
|
48
51
|
const [hiddenSidebar, setHiddenSidebar] = useState(false);
|
|
49
52
|
const toggleSidebar = useCallback(() => {
|
|
@@ -150,17 +153,30 @@ function DocPage(props: Props): JSX.Element {
|
|
|
150
153
|
if (!currentDocRoute) {
|
|
151
154
|
return <NotFound />;
|
|
152
155
|
}
|
|
156
|
+
|
|
157
|
+
// For now, the sidebarName is added as route config: not ideal!
|
|
158
|
+
const sidebarName = currentDocRoute.sidebar;
|
|
159
|
+
|
|
160
|
+
const sidebar = sidebarName
|
|
161
|
+
? versionMetadata.docsSidebars[sidebarName]
|
|
162
|
+
: null;
|
|
163
|
+
|
|
153
164
|
return (
|
|
154
165
|
<>
|
|
155
166
|
<Head>
|
|
156
167
|
{/* TODO we should add a core addRoute({htmlClassName}) generic plugin option */}
|
|
157
168
|
<html className={versionMetadata.className} />
|
|
158
169
|
</Head>
|
|
159
|
-
<
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
170
|
+
<DocsVersionProvider version={versionMetadata}>
|
|
171
|
+
<DocsSidebarProvider sidebar={sidebar}>
|
|
172
|
+
<DocPageContent
|
|
173
|
+
currentDocRoute={currentDocRoute}
|
|
174
|
+
versionMetadata={versionMetadata}
|
|
175
|
+
sidebarName={sidebarName}>
|
|
176
|
+
{renderRoutes(docRoutes, {versionMetadata})}
|
|
177
|
+
</DocPageContent>
|
|
178
|
+
</DocsSidebarProvider>
|
|
179
|
+
</DocsVersionProvider>
|
|
164
180
|
</>
|
|
165
181
|
);
|
|
166
182
|
}
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import Link from '@docusaurus/Link';
|
|
10
10
|
import Translate, {translate} from '@docusaurus/Translate';
|
|
11
|
-
import type {
|
|
11
|
+
import type {PropNavigation} from '@docusaurus/plugin-content-docs';
|
|
12
12
|
|
|
13
|
-
function DocPaginator(props:
|
|
14
|
-
const {
|
|
13
|
+
function DocPaginator(props: PropNavigation): JSX.Element {
|
|
14
|
+
const {previous, next} = props;
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
17
|
<nav
|
|
@@ -22,10 +22,8 @@ function DocPaginator(props: Props): JSX.Element {
|
|
|
22
22
|
description: 'The ARIA label for the docs pagination',
|
|
23
23
|
})}>
|
|
24
24
|
<div className="pagination-nav__item">
|
|
25
|
-
{
|
|
26
|
-
<Link
|
|
27
|
-
className="pagination-nav__link"
|
|
28
|
-
to={metadata.previous.permalink}>
|
|
25
|
+
{previous && (
|
|
26
|
+
<Link className="pagination-nav__link" to={previous.permalink}>
|
|
29
27
|
<div className="pagination-nav__sublabel">
|
|
30
28
|
<Translate
|
|
31
29
|
id="theme.docs.paginator.previous"
|
|
@@ -34,14 +32,14 @@ function DocPaginator(props: Props): JSX.Element {
|
|
|
34
32
|
</Translate>
|
|
35
33
|
</div>
|
|
36
34
|
<div className="pagination-nav__label">
|
|
37
|
-
« {
|
|
35
|
+
« {previous.title}
|
|
38
36
|
</div>
|
|
39
37
|
</Link>
|
|
40
38
|
)}
|
|
41
39
|
</div>
|
|
42
40
|
<div className="pagination-nav__item pagination-nav__item--next">
|
|
43
|
-
{
|
|
44
|
-
<Link className="pagination-nav__link" to={
|
|
41
|
+
{next && (
|
|
42
|
+
<Link className="pagination-nav__link" to={next.permalink}>
|
|
45
43
|
<div className="pagination-nav__sublabel">
|
|
46
44
|
<Translate
|
|
47
45
|
id="theme.docs.paginator.next"
|
|
@@ -49,9 +47,7 @@ function DocPaginator(props: Props): JSX.Element {
|
|
|
49
47
|
Next
|
|
50
48
|
</Translate>
|
|
51
49
|
</div>
|
|
52
|
-
<div className="pagination-nav__label">
|
|
53
|
-
{metadata.next.title} »
|
|
54
|
-
</div>
|
|
50
|
+
<div className="pagination-nav__label">{next.title} »</div>
|
|
55
51
|
</Link>
|
|
56
52
|
)}
|
|
57
53
|
</div>
|
|
@@ -100,7 +100,15 @@ const DocSidebarMobileSecondaryMenu: MobileSecondaryMenuComponent<Props> = ({
|
|
|
100
100
|
<DocSidebarItems
|
|
101
101
|
items={sidebar}
|
|
102
102
|
activePath={path}
|
|
103
|
-
onItemClick={() =>
|
|
103
|
+
onItemClick={(item) => {
|
|
104
|
+
// Mobile sidebar should only be closed if the category has a link
|
|
105
|
+
if (item.type === 'category' && item.href) {
|
|
106
|
+
toggleSidebar();
|
|
107
|
+
}
|
|
108
|
+
if (item.type === 'link') {
|
|
109
|
+
toggleSidebar();
|
|
110
|
+
}
|
|
111
|
+
}}
|
|
104
112
|
level={1}
|
|
105
113
|
/>
|
|
106
114
|
</ul>
|