@docusaurus/theme-classic 0.0.0-4224 → 0.0.0-4241
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/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/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 +16 -16
- 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
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = DocCard;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _Link = _interopRequireDefault(require("@docusaurus/Link"));
|
|
11
|
+
|
|
12
|
+
var _themeCommon = require("@docusaurus/theme-common");
|
|
13
|
+
|
|
14
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
15
|
+
|
|
16
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.css"));
|
|
17
|
+
|
|
18
|
+
var _isInternalUrl = _interopRequireDefault(require("@docusaurus/isInternalUrl"));
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the MIT license found in the
|
|
26
|
+
* LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/
|
|
28
|
+
function CardContainer({
|
|
29
|
+
href,
|
|
30
|
+
children
|
|
31
|
+
}) {
|
|
32
|
+
const className = (0, _clsx.default)('card margin-bottom--lg padding--lg', _stylesModule.default.cardContainer, href && _stylesModule.default.cardContainerLink);
|
|
33
|
+
return href ? <_Link.default href={href} className={className}>
|
|
34
|
+
{children}
|
|
35
|
+
</_Link.default> : <div className={className}>{children}</div>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function CardLayout({
|
|
39
|
+
href,
|
|
40
|
+
icon,
|
|
41
|
+
title,
|
|
42
|
+
description
|
|
43
|
+
}) {
|
|
44
|
+
return <CardContainer href={href}>
|
|
45
|
+
<h2 className={(0, _clsx.default)('text--truncate', _stylesModule.default.cardTitle)} title={title}>
|
|
46
|
+
{icon} {title}
|
|
47
|
+
</h2>
|
|
48
|
+
<div className={(0, _clsx.default)('text--truncate', _stylesModule.default.cardDescription)} title={description}>
|
|
49
|
+
{description}
|
|
50
|
+
</div>
|
|
51
|
+
</CardContainer>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function CardCategory({
|
|
55
|
+
item
|
|
56
|
+
}) {
|
|
57
|
+
const href = (0, _themeCommon.findFirstCategoryLink)(item);
|
|
58
|
+
return <CardLayout href={href} icon="🗃️" title={item.label} description={`${item.items.length} items`} />;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function CardLink({
|
|
62
|
+
item
|
|
63
|
+
}) {
|
|
64
|
+
var _item$docId;
|
|
65
|
+
|
|
66
|
+
const icon = (0, _isInternalUrl.default)(item.href) ? '📄️' : '🔗';
|
|
67
|
+
const doc = (0, _themeCommon.useDocById)((_item$docId = item.docId) !== null && _item$docId !== void 0 ? _item$docId : undefined);
|
|
68
|
+
return <CardLayout href={item.href} icon={icon} title={item.label} description={doc === null || doc === void 0 ? void 0 : doc.description} />;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function DocCard({
|
|
72
|
+
item
|
|
73
|
+
}) {
|
|
74
|
+
switch (item.type) {
|
|
75
|
+
case 'link':
|
|
76
|
+
return <CardLink item={item} />;
|
|
77
|
+
|
|
78
|
+
case 'category':
|
|
79
|
+
return <CardCategory item={item} />;
|
|
80
|
+
|
|
81
|
+
default:
|
|
82
|
+
throw new Error(`unknown item type ${JSON.stringify(item)}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -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,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = DocCardList;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _DocCard = _interopRequireDefault(require("@theme/DocCard"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
16
|
+
*
|
|
17
|
+
* This source code is licensed under the MIT license found in the
|
|
18
|
+
* LICENSE file in the root directory of this source tree.
|
|
19
|
+
*/
|
|
20
|
+
function DocCardList({
|
|
21
|
+
items
|
|
22
|
+
}) {
|
|
23
|
+
return <div className="row">
|
|
24
|
+
{items.map((item, index) => <article key={index} className="col col--6">
|
|
25
|
+
<_DocCard.default item={item} />
|
|
26
|
+
</article>)}
|
|
27
|
+
</div>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = DocCategoryGeneratedIndexPage;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _themeCommon = require("@docusaurus/theme-common");
|
|
11
|
+
|
|
12
|
+
var _DocCardList = _interopRequireDefault(require("@theme/DocCardList"));
|
|
13
|
+
|
|
14
|
+
var _DocPaginator = _interopRequireDefault(require("@theme/DocPaginator"));
|
|
15
|
+
|
|
16
|
+
var _Seo = _interopRequireDefault(require("@theme/Seo"));
|
|
17
|
+
|
|
18
|
+
var _DocVersionBanner = _interopRequireDefault(require("@theme/DocVersionBanner"));
|
|
19
|
+
|
|
20
|
+
var _DocVersionBadge = _interopRequireDefault(require("@theme/DocVersionBadge"));
|
|
21
|
+
|
|
22
|
+
var _Heading = require("@theme/Heading");
|
|
23
|
+
|
|
24
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.css"));
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/
|
|
34
|
+
function DocCategoryGeneratedIndexPage({
|
|
35
|
+
categoryGeneratedIndex
|
|
36
|
+
}) {
|
|
37
|
+
const category = (0, _themeCommon.useCurrentSidebarCategory)();
|
|
38
|
+
return <>
|
|
39
|
+
<_Seo.default title={categoryGeneratedIndex.title} description={categoryGeneratedIndex.description} />
|
|
40
|
+
<div className={_stylesModule.default.generatedIndexPage}>
|
|
41
|
+
<_DocVersionBanner.default />
|
|
42
|
+
<_DocVersionBadge.default />
|
|
43
|
+
<header>
|
|
44
|
+
<_Heading.MainHeading className={_stylesModule.default.title}>
|
|
45
|
+
{categoryGeneratedIndex.title}
|
|
46
|
+
</_Heading.MainHeading>
|
|
47
|
+
{categoryGeneratedIndex.description && <p>{categoryGeneratedIndex.description}</p>}
|
|
48
|
+
</header>
|
|
49
|
+
<main className="margin-top--lg">
|
|
50
|
+
<_DocCardList.default items={category.items} />
|
|
51
|
+
</main>
|
|
52
|
+
<footer className="margin-top--lg">
|
|
53
|
+
<_DocPaginator.default previous={categoryGeneratedIndex.navigation.previous} next={categoryGeneratedIndex.navigation.next} />
|
|
54
|
+
</footer>
|
|
55
|
+
</div>
|
|
56
|
+
</>;
|
|
57
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -15,6 +15,8 @@ var _DocPaginator = _interopRequireDefault(require("@theme/DocPaginator"));
|
|
|
15
15
|
|
|
16
16
|
var _DocVersionBanner = _interopRequireDefault(require("@theme/DocVersionBanner"));
|
|
17
17
|
|
|
18
|
+
var _DocVersionBadge = _interopRequireDefault(require("@theme/DocVersionBadge"));
|
|
19
|
+
|
|
18
20
|
var _Seo = _interopRequireDefault(require("@theme/Seo"));
|
|
19
21
|
|
|
20
22
|
var _DocItemFooter = _interopRequireDefault(require("@theme/DocItemFooter"));
|
|
@@ -39,8 +41,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
39
41
|
*/
|
|
40
42
|
function DocItem(props) {
|
|
41
43
|
const {
|
|
42
|
-
content: DocContent
|
|
43
|
-
versionMetadata
|
|
44
|
+
content: DocContent
|
|
44
45
|
} = props;
|
|
45
46
|
const {
|
|
46
47
|
metadata,
|
|
@@ -77,12 +78,10 @@ function DocItem(props) {
|
|
|
77
78
|
<div className={(0, _clsx.default)('col', {
|
|
78
79
|
[_stylesModule.default.docItemCol]: !hideTableOfContents
|
|
79
80
|
})}>
|
|
80
|
-
<_DocVersionBanner.default
|
|
81
|
+
<_DocVersionBanner.default />
|
|
81
82
|
<div className={_stylesModule.default.docItemContainer}>
|
|
82
83
|
<article>
|
|
83
|
-
|
|
84
|
-
Version: {versionMetadata.label}
|
|
85
|
-
</span>}
|
|
84
|
+
<_DocVersionBadge.default />
|
|
86
85
|
|
|
87
86
|
{canRenderTOC && <_TOCCollapsible.default toc={DocContent.toc} minHeadingLevel={tocMinHeadingLevel} maxHeadingLevel={tocMaxHeadingLevel} className={(0, _clsx.default)(_themeCommon.ThemeClassNames.docs.docTocMobile, _stylesModule.default.tocMobile)} />}
|
|
88
87
|
|
|
@@ -102,7 +101,7 @@ function DocItem(props) {
|
|
|
102
101
|
<_DocItemFooter.default {...props} />
|
|
103
102
|
</article>
|
|
104
103
|
|
|
105
|
-
<_DocPaginator.default metadata={metadata} />
|
|
104
|
+
<_DocPaginator.default previous={metadata.previous} next={metadata.next} />
|
|
106
105
|
</div>
|
|
107
106
|
</div>
|
|
108
107
|
{renderTocDesktop && <div className="col col--3">
|
|
@@ -50,14 +50,14 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
50
50
|
function DocPageContent({
|
|
51
51
|
currentDocRoute,
|
|
52
52
|
versionMetadata,
|
|
53
|
-
children
|
|
53
|
+
children,
|
|
54
|
+
sidebarName
|
|
54
55
|
}) {
|
|
56
|
+
const sidebar = (0, _themeCommon.useDocsSidebar)();
|
|
55
57
|
const {
|
|
56
58
|
pluginId,
|
|
57
59
|
version
|
|
58
60
|
} = versionMetadata;
|
|
59
|
-
const sidebarName = currentDocRoute.sidebar;
|
|
60
|
-
const sidebar = sidebarName ? versionMetadata.docsSidebars[sidebarName] : undefined;
|
|
61
61
|
const [hiddenSidebarContainer, setHiddenSidebarContainer] = (0, _react.useState)(false);
|
|
62
62
|
const [hiddenSidebar, setHiddenSidebar] = (0, _react.useState)(false);
|
|
63
63
|
const toggleSidebar = (0, _react.useCallback)(() => {
|
|
@@ -126,8 +126,11 @@ function DocPage(props) {
|
|
|
126
126
|
|
|
127
127
|
if (!currentDocRoute) {
|
|
128
128
|
return <_NotFound.default />;
|
|
129
|
-
}
|
|
129
|
+
} // For now, the sidebarName is added as route config: not ideal!
|
|
130
|
+
|
|
130
131
|
|
|
132
|
+
const sidebarName = currentDocRoute.sidebar;
|
|
133
|
+
const sidebar = sidebarName ? versionMetadata.docsSidebars[sidebarName] : null;
|
|
131
134
|
return <>
|
|
132
135
|
<_Head.default>
|
|
133
136
|
{
|
|
@@ -135,11 +138,15 @@ function DocPage(props) {
|
|
|
135
138
|
}
|
|
136
139
|
<html className={versionMetadata.className} />
|
|
137
140
|
</_Head.default>
|
|
138
|
-
<
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
<_themeCommon.DocsVersionProvider version={versionMetadata}>
|
|
142
|
+
<_themeCommon.DocsSidebarProvider sidebar={sidebar}>
|
|
143
|
+
<DocPageContent currentDocRoute={currentDocRoute} versionMetadata={versionMetadata} sidebarName={sidebarName}>
|
|
144
|
+
{(0, _renderRoutes.default)(docRoutes, {
|
|
145
|
+
versionMetadata
|
|
146
|
+
})}
|
|
147
|
+
</DocPageContent>
|
|
148
|
+
</_themeCommon.DocsSidebarProvider>
|
|
149
|
+
</_themeCommon.DocsVersionProvider>
|
|
143
150
|
</>;
|
|
144
151
|
}
|
|
145
152
|
|
|
@@ -25,7 +25,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
25
|
*/
|
|
26
26
|
function DocPaginator(props) {
|
|
27
27
|
const {
|
|
28
|
-
|
|
28
|
+
previous,
|
|
29
|
+
next
|
|
29
30
|
} = props;
|
|
30
31
|
return <nav className="pagination-nav docusaurus-mt-lg" aria-label={(0, _Translate.translate)({
|
|
31
32
|
id: 'theme.docs.paginator.navAriaLabel',
|
|
@@ -33,27 +34,25 @@ function DocPaginator(props) {
|
|
|
33
34
|
description: 'The ARIA label for the docs pagination'
|
|
34
35
|
})}>
|
|
35
36
|
<div className="pagination-nav__item">
|
|
36
|
-
{
|
|
37
|
+
{previous && <_Link.default className="pagination-nav__link" to={previous.permalink}>
|
|
37
38
|
<div className="pagination-nav__sublabel">
|
|
38
39
|
<_Translate.default id="theme.docs.paginator.previous" description="The label used to navigate to the previous doc">
|
|
39
40
|
Previous
|
|
40
41
|
</_Translate.default>
|
|
41
42
|
</div>
|
|
42
43
|
<div className="pagination-nav__label">
|
|
43
|
-
« {
|
|
44
|
+
« {previous.title}
|
|
44
45
|
</div>
|
|
45
46
|
</_Link.default>}
|
|
46
47
|
</div>
|
|
47
48
|
<div className="pagination-nav__item pagination-nav__item--next">
|
|
48
|
-
{
|
|
49
|
+
{next && <_Link.default className="pagination-nav__link" to={next.permalink}>
|
|
49
50
|
<div className="pagination-nav__sublabel">
|
|
50
51
|
<_Translate.default id="theme.docs.paginator.next" description="The label used to navigate to the next doc">
|
|
51
52
|
Next
|
|
52
53
|
</_Translate.default>
|
|
53
54
|
</div>
|
|
54
|
-
<div className="pagination-nav__label">
|
|
55
|
-
{metadata.next.title} »
|
|
56
|
-
</div>
|
|
55
|
+
<div className="pagination-nav__label">{next.title} »</div>
|
|
57
56
|
</_Link.default>}
|
|
58
57
|
</div>
|
|
59
58
|
</nav>;
|
|
@@ -101,7 +101,16 @@ const DocSidebarMobileSecondaryMenu = ({
|
|
|
101
101
|
sidebar,
|
|
102
102
|
path
|
|
103
103
|
}) => <ul className={(0, _clsx.default)(_themeCommon.ThemeClassNames.docs.docSidebarMenu, 'menu__list')}>
|
|
104
|
-
<_DocSidebarItem.DocSidebarItems items={sidebar} activePath={path} onItemClick={
|
|
104
|
+
<_DocSidebarItem.DocSidebarItems items={sidebar} activePath={path} onItemClick={item => {
|
|
105
|
+
// Mobile sidebar should only be closed if the category has a link
|
|
106
|
+
if (item.type === 'category' && item.href) {
|
|
107
|
+
toggleSidebar();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (item.type === 'link') {
|
|
111
|
+
toggleSidebar();
|
|
112
|
+
}
|
|
113
|
+
}} level={1} />
|
|
105
114
|
</ul>;
|
|
106
115
|
|
|
107
116
|
function DocSidebarMobile(props) {
|
|
@@ -16,10 +16,14 @@ var _Link = _interopRequireDefault(require("@docusaurus/Link"));
|
|
|
16
16
|
|
|
17
17
|
var _isInternalUrl = _interopRequireDefault(require("@docusaurus/isInternalUrl"));
|
|
18
18
|
|
|
19
|
+
var _Translate = require("@docusaurus/Translate");
|
|
20
|
+
|
|
19
21
|
var _IconExternalLink = _interopRequireDefault(require("@theme/IconExternalLink"));
|
|
20
22
|
|
|
21
23
|
var _stylesModule = _interopRequireDefault(require("./styles.module.css"));
|
|
22
24
|
|
|
25
|
+
var _useIsBrowser = _interopRequireDefault(require("@docusaurus/useIsBrowser"));
|
|
26
|
+
|
|
23
27
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
28
|
|
|
25
29
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -32,21 +36,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
32
36
|
* This source code is licensed under the MIT license found in the
|
|
33
37
|
* LICENSE file in the root directory of this source tree.
|
|
34
38
|
*/
|
|
35
|
-
|
|
36
|
-
if (item.type === 'link') {
|
|
37
|
-
return (0, _themeCommon.isSamePath)(item.href, activePath);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (item.type === 'category') {
|
|
41
|
-
return item.items.some(subItem => isActiveSidebarItem(subItem, activePath));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return false;
|
|
45
|
-
}; // Optimize sidebar at each "level"
|
|
39
|
+
// Optimize sidebar at each "level"
|
|
46
40
|
// TODO this item should probably not receive the "activePath" props
|
|
47
41
|
// TODO this triggers whole sidebar re-renders on navigation
|
|
48
|
-
|
|
49
|
-
|
|
50
42
|
const DocSidebarItems = (0, _react.memo)(({
|
|
51
43
|
items,
|
|
52
44
|
...props
|
|
@@ -88,6 +80,28 @@ function useAutoExpandActiveCategory({
|
|
|
88
80
|
setCollapsed(false);
|
|
89
81
|
}
|
|
90
82
|
}, [isActive, wasActive, collapsed, setCollapsed]);
|
|
83
|
+
} // When a collapsible category has no link, we still link it to its first child during SSR as a temporary fallback
|
|
84
|
+
// This allows to be able to navigate inside the category even when JS fails to load, is delayed or simply disabled
|
|
85
|
+
// React hydration becomes an optional progressive enhancement
|
|
86
|
+
// see https://github.com/facebookincubator/infima/issues/36#issuecomment-772543188
|
|
87
|
+
// see https://github.com/facebook/docusaurus/issues/3030
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
function useCategoryHrefWithSSRFallback(item) {
|
|
91
|
+
const isBrowser = (0, _useIsBrowser.default)();
|
|
92
|
+
return (0, _react.useMemo)(() => {
|
|
93
|
+
if (item.href) {
|
|
94
|
+
return item.href;
|
|
95
|
+
} // In these cases, it's not necessary to render a fallback
|
|
96
|
+
// We skip the "findFirstCategoryLink" computation
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
if (isBrowser || !item.collapsible) {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return (0, _themeCommon.findFirstCategoryLink)(item);
|
|
104
|
+
}, [item, isBrowser]);
|
|
91
105
|
}
|
|
92
106
|
|
|
93
107
|
function DocSidebarItemCategory({
|
|
@@ -101,9 +115,11 @@ function DocSidebarItemCategory({
|
|
|
101
115
|
items,
|
|
102
116
|
label,
|
|
103
117
|
collapsible,
|
|
104
|
-
className
|
|
118
|
+
className,
|
|
119
|
+
href
|
|
105
120
|
} = item;
|
|
106
|
-
const
|
|
121
|
+
const hrefWithSSRFallback = useCategoryHrefWithSSRFallback(item);
|
|
122
|
+
const isActive = (0, _themeCommon.isActiveSidebarItem)(item, activePath);
|
|
107
123
|
const {
|
|
108
124
|
collapsed,
|
|
109
125
|
setCollapsed,
|
|
@@ -127,19 +143,37 @@ function DocSidebarItemCategory({
|
|
|
127
143
|
return <li className={(0, _clsx.default)(_themeCommon.ThemeClassNames.docs.docSidebarItemCategory, _themeCommon.ThemeClassNames.docs.docSidebarItemCategoryLevel(level), 'menu__list-item', {
|
|
128
144
|
'menu__list-item--collapsed': collapsed
|
|
129
145
|
}, className)}>
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
{
|
|
142
|
-
|
|
146
|
+
<div className="menu__list-item-collapsible">
|
|
147
|
+
<_Link.default className={(0, _clsx.default)('menu__link', {
|
|
148
|
+
'menu__link--sublist': collapsible && !href,
|
|
149
|
+
'menu__link--active': isActive,
|
|
150
|
+
[_stylesModule.default.menuLinkText]: !collapsible,
|
|
151
|
+
[_stylesModule.default.hasHref]: !!hrefWithSSRFallback
|
|
152
|
+
})} onClick={collapsible ? e => {
|
|
153
|
+
onItemClick === null || onItemClick === void 0 ? void 0 : onItemClick(item);
|
|
154
|
+
|
|
155
|
+
if (href) {
|
|
156
|
+
setCollapsed(false);
|
|
157
|
+
} else {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
toggleCollapsed();
|
|
160
|
+
}
|
|
161
|
+
} : () => {
|
|
162
|
+
onItemClick === null || onItemClick === void 0 ? void 0 : onItemClick(item);
|
|
163
|
+
}} href={collapsible ? hrefWithSSRFallback !== null && hrefWithSSRFallback !== void 0 ? hrefWithSSRFallback : '#' : hrefWithSSRFallback} {...props}>
|
|
164
|
+
{label}
|
|
165
|
+
</_Link.default>
|
|
166
|
+
{href && collapsible && <button aria-label={(0, _Translate.translate)({
|
|
167
|
+
id: 'theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel',
|
|
168
|
+
message: "Toggle the collapsible sidebar category '{label}'",
|
|
169
|
+
description: 'The ARIA label to toggle the collapsible sidebar category'
|
|
170
|
+
}, {
|
|
171
|
+
label
|
|
172
|
+
})} type="button" className="clean-btn menu__caret" onClick={e => {
|
|
173
|
+
e.preventDefault();
|
|
174
|
+
toggleCollapsed();
|
|
175
|
+
}} />}
|
|
176
|
+
</div>
|
|
143
177
|
|
|
144
178
|
<_themeCommon.Collapsible lazy as="ul" className="menu__list" collapsed={collapsed}>
|
|
145
179
|
<DocSidebarItems items={items} tabIndex={collapsed ? -1 : 0} onItemClick={onItemClick} activePath={activePath} level={level + 1} />
|
|
@@ -159,12 +193,12 @@ function DocSidebarItemLink({
|
|
|
159
193
|
label,
|
|
160
194
|
className
|
|
161
195
|
} = item;
|
|
162
|
-
const isActive = isActiveSidebarItem(item, activePath);
|
|
196
|
+
const isActive = (0, _themeCommon.isActiveSidebarItem)(item, activePath);
|
|
163
197
|
return <li className={(0, _clsx.default)(_themeCommon.ThemeClassNames.docs.docSidebarItemLink, _themeCommon.ThemeClassNames.docs.docSidebarItemLinkLevel(level), 'menu__list-item', className)} key={label}>
|
|
164
198
|
<_Link.default className={(0, _clsx.default)('menu__link', {
|
|
165
199
|
'menu__link--active': isActive
|
|
166
200
|
})} aria-current={isActive ? 'page' : undefined} to={href} {...(0, _isInternalUrl.default)(href) && {
|
|
167
|
-
onClick: onItemClick
|
|
201
|
+
onClick: onItemClick ? () => onItemClick(item) : undefined
|
|
168
202
|
}} {...props}>
|
|
169
203
|
{(0, _isInternalUrl.default)(href) ? label : <span>
|
|
170
204
|
{label}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = DocVersionBadge;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _themeCommon = require("@docusaurus/theme-common");
|
|
11
|
+
|
|
12
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the MIT license found in the
|
|
20
|
+
* LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/
|
|
22
|
+
function DocVersionBadge({
|
|
23
|
+
className
|
|
24
|
+
}) {
|
|
25
|
+
const versionMetadata = (0, _themeCommon.useDocsVersion)();
|
|
26
|
+
|
|
27
|
+
if (versionMetadata.badge) {
|
|
28
|
+
return <span className={(0, _clsx.default)(className, _themeCommon.ThemeClassNames.docs.docVersionBadge, 'badge badge--secondary')}>
|
|
29
|
+
Version: {versionMetadata.label}
|
|
30
|
+
</span>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = DocVersionBanner;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
@@ -81,6 +81,7 @@ function LatestVersionSuggestionLabel({
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
function DocVersionBannerEnabled({
|
|
84
|
+
className,
|
|
84
85
|
versionMetadata
|
|
85
86
|
}) {
|
|
86
87
|
const {
|
|
@@ -106,7 +107,7 @@ function DocVersionBannerEnabled({
|
|
|
106
107
|
// fallback to main doc of latest version
|
|
107
108
|
|
|
108
109
|
const latestVersionSuggestedDoc = latestDocSuggestion !== null && latestDocSuggestion !== void 0 ? latestDocSuggestion : getVersionMainDoc(latestVersionSuggestion);
|
|
109
|
-
return <div className={(0, _clsx.default)(_themeCommon.ThemeClassNames.docs.docVersionBanner, 'alert alert--warning margin-bottom--md')} role="alert">
|
|
110
|
+
return <div className={(0, _clsx.default)(className, _themeCommon.ThemeClassNames.docs.docVersionBanner, 'alert alert--warning margin-bottom--md')} role="alert">
|
|
110
111
|
<div>
|
|
111
112
|
<BannerLabel siteTitle={siteTitle} versionMetadata={versionMetadata} />
|
|
112
113
|
</div>
|
|
@@ -117,14 +118,13 @@ function DocVersionBannerEnabled({
|
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
function DocVersionBanner({
|
|
120
|
-
|
|
121
|
+
className
|
|
121
122
|
}) {
|
|
123
|
+
const versionMetadata = (0, _themeCommon.useDocsVersion)();
|
|
124
|
+
|
|
122
125
|
if (versionMetadata.banner) {
|
|
123
|
-
return <DocVersionBannerEnabled versionMetadata={versionMetadata} />;
|
|
126
|
+
return <DocVersionBannerEnabled className={className} versionMetadata={versionMetadata} />;
|
|
124
127
|
}
|
|
125
128
|
|
|
126
129
|
return null;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
var _default = DocVersionBanner;
|
|
130
|
-
exports.default = _default;
|
|
130
|
+
}
|
package/lib/theme-classic.d.ts
CHANGED
|
@@ -107,11 +107,12 @@ declare module '@theme/CodeBlock' {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
declare module '@theme/DocPaginator' {
|
|
110
|
+
import type {PropNavigation} from '@docusaurus/plugin-content-docs';
|
|
111
|
+
|
|
110
112
|
type PageInfo = {readonly permalink: string; readonly title: string};
|
|
111
113
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
114
|
+
// May be simpler to provide a {navigation: PropNavigation} prop?
|
|
115
|
+
export interface Props extends PropNavigation {}
|
|
115
116
|
|
|
116
117
|
const DocPaginator: (props: Props) => JSX.Element;
|
|
117
118
|
export default DocPaginator;
|
|
@@ -138,7 +139,7 @@ declare module '@theme/DocSidebarItem' {
|
|
|
138
139
|
|
|
139
140
|
type DocSidebarPropsBase = {
|
|
140
141
|
readonly activePath: string;
|
|
141
|
-
readonly onItemClick?: () => void;
|
|
142
|
+
readonly onItemClick?: (item: PropSidebarItem) => void;
|
|
142
143
|
readonly level: number;
|
|
143
144
|
readonly tabIndex?: number;
|
|
144
145
|
};
|