@docusaurus/theme-classic 2.0.0-beta.1ab8aa0af → 2.0.0-beta.2
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/codeTranslations/ar.json +2 -0
- package/codeTranslations/base.json +4 -0
- package/codeTranslations/bn.json +56 -0
- package/codeTranslations/da.json +2 -0
- package/codeTranslations/de.json +2 -0
- package/codeTranslations/es.json +2 -0
- package/codeTranslations/fa.json +2 -0
- package/codeTranslations/fil.json +2 -0
- package/codeTranslations/fr.json +2 -0
- package/codeTranslations/he.json +18 -16
- package/codeTranslations/hi.json +2 -0
- package/codeTranslations/ja.json +2 -0
- package/codeTranslations/ko.json +2 -0
- package/codeTranslations/pl.json +2 -0
- package/codeTranslations/pt-BR.json +2 -0
- package/codeTranslations/pt-PT.json +2 -0
- package/codeTranslations/ru.json +2 -0
- package/codeTranslations/tr.json +2 -0
- package/codeTranslations/vi.json +2 -0
- package/codeTranslations/zh-Hans.json +2 -0
- package/codeTranslations/zh-Hant.json +2 -0
- package/lib/index.js +28 -7
- package/lib/theme/AnnouncementBar/index.js +5 -7
- package/lib/theme/AnnouncementBar/styles.module.css +6 -6
- package/lib/theme/BlogListPage/index.js +2 -2
- package/lib/theme/BlogListPaginator/index.js +2 -2
- package/lib/theme/BlogPostItem/index.js +32 -23
- package/lib/theme/BlogPostItem/styles.module.css +5 -1
- package/lib/theme/BlogPostPage/index.js +4 -10
- package/lib/theme/BlogPostPaginator/index.js +3 -3
- package/lib/theme/BlogSidebar/index.js +11 -3
- package/lib/theme/BlogSidebar/styles.module.css +4 -6
- package/lib/theme/BlogTagsListPage/index.js +15 -20
- package/lib/theme/BlogTagsPostsPage/index.js +29 -33
- package/lib/theme/CodeBlock/index.js +11 -11
- package/lib/theme/CodeBlock/styles.module.css +4 -7
- package/lib/theme/DocItem/index.js +35 -26
- package/lib/theme/DocItem/styles.module.css +8 -10
- package/lib/theme/DocPage/index.js +43 -11
- package/lib/theme/DocPage/styles.module.css +7 -19
- package/lib/theme/DocPaginator/index.js +3 -3
- package/lib/theme/DocSidebar/index.js +23 -24
- package/lib/theme/DocSidebar/styles.module.css +0 -14
- package/lib/theme/DocVersionBanner/index.js +128 -0
- package/lib/theme/DocVersionSuggestions/index.js +4 -4
- package/lib/theme/Heading/index.js +18 -2
- package/lib/theme/Heading/styles.module.css +5 -0
- package/lib/theme/IconArrow/index.js +1 -1
- package/lib/theme/IconEdit/index.js +1 -1
- package/lib/theme/IconExternalLink/index.js +30 -0
- package/lib/theme/IconExternalLink/styles.module.css +12 -0
- package/lib/theme/IconLanguage/index.js +1 -1
- package/lib/theme/IconMenu/index.js +1 -2
- package/lib/theme/LastUpdated/index.js +17 -21
- package/lib/theme/Layout/styles.css +6 -0
- package/lib/theme/LayoutHead/index.js +3 -1
- package/lib/theme/LayoutProviders/index.js +7 -5
- package/lib/theme/Logo/index.js +13 -12
- package/lib/theme/MDXComponents/index.js +2 -2
- package/lib/theme/MDXPage/index.js +13 -15
- package/{src/theme/LastUpdated → lib/theme/MDXPage}/styles.module.css +2 -2
- package/lib/theme/Navbar/index.js +4 -4
- package/lib/theme/Navbar/styles.module.css +1 -1
- package/lib/theme/NavbarItem/DefaultNavbarItem.js +18 -4
- package/lib/theme/NavbarItem/DocNavbarItem.js +19 -11
- package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +5 -4
- package/lib/theme/NavbarItem/SearchNavbarItem.js +1 -5
- package/lib/theme/NavbarItem/index.js +1 -1
- package/lib/theme/NotFound.js +9 -2
- package/lib/theme/SearchMetadatas/index.js +1 -1
- package/lib/theme/Seo/index.js +0 -1
- package/lib/theme/SkipToContent/index.js +6 -4
- package/lib/theme/SkipToContent/styles.module.css +1 -3
- package/lib/theme/TOC/styles.module.css +1 -1
- package/lib/theme/Tabs/index.js +2 -2
- package/lib/theme/ThemedImage/index.js +2 -1
- package/lib/theme/ThemedImage/styles.module.css +7 -0
- package/lib/theme/Toggle/index.js +12 -24
- package/lib/theme/Toggle/styles.css +103 -0
- package/lib/theme/Toggle/styles.module.css +0 -97
- package/lib/theme/UserPreferencesProvider/index.js +1 -9
- package/lib/theme/hooks/useHideableNavbar.js +2 -2
- package/lib/theme/hooks/useTabGroupChoice.js +2 -4
- package/lib/theme/hooks/useThemeContext.js +1 -1
- package/lib/theme/hooks/useUserPreferencesContext.js +1 -1
- package/lib/types.d.ts +10 -12
- package/lib/validateThemeConfig.js +3 -3
- package/lib-next/index.js +31 -8
- package/lib-next/theme/AnnouncementBar/index.js +5 -9
- package/lib-next/theme/AnnouncementBar/styles.module.css +6 -6
- package/lib-next/theme/BlogListPage/index.js +2 -2
- package/lib-next/theme/BlogPostItem/index.js +41 -24
- package/lib-next/theme/BlogPostItem/styles.module.css +5 -1
- package/lib-next/theme/BlogPostPage/index.js +4 -8
- package/lib-next/theme/BlogPostPaginator/index.js +1 -1
- package/lib-next/theme/BlogSidebar/index.js +12 -3
- package/lib-next/theme/BlogSidebar/styles.module.css +4 -6
- package/lib-next/theme/BlogTagsListPage/index.js +17 -23
- package/lib-next/theme/BlogTagsPostsPage/index.js +36 -40
- package/lib-next/theme/CodeBlock/index.js +10 -9
- package/lib-next/theme/CodeBlock/styles.module.css +4 -7
- package/lib-next/theme/DocItem/index.js +41 -41
- package/lib-next/theme/DocItem/styles.module.css +8 -10
- package/lib-next/theme/DocPage/index.js +36 -9
- package/lib-next/theme/DocPage/styles.module.css +7 -19
- package/lib-next/theme/DocPaginator/index.js +1 -1
- package/lib-next/theme/DocSidebar/index.js +28 -21
- package/lib-next/theme/DocSidebar/styles.module.css +0 -14
- package/lib-next/theme/DocVersionBanner/index.js +127 -0
- package/lib-next/theme/DocVersionSuggestions/index.js +4 -4
- package/lib-next/theme/Heading/index.js +17 -1
- package/lib-next/theme/Heading/styles.module.css +5 -0
- package/lib-next/theme/IconArrow/index.js +1 -1
- package/lib-next/theme/IconEdit/index.js +3 -5
- package/lib-next/theme/IconExternalLink/index.js +26 -0
- package/{lib/theme/NavbarItem → lib-next/theme/IconExternalLink}/styles.module.css +4 -5
- package/lib-next/theme/IconLanguage/index.js +1 -1
- package/lib-next/theme/IconMenu/index.js +1 -4
- package/lib-next/theme/LastUpdated/index.js +34 -39
- package/lib-next/theme/Layout/styles.css +6 -0
- package/lib-next/theme/LayoutHead/index.js +5 -1
- package/lib-next/theme/LayoutProviders/index.js +11 -6
- package/lib-next/theme/Logo/index.js +12 -8
- package/lib-next/theme/MDXPage/index.js +13 -17
- package/lib-next/theme/{LastUpdated → MDXPage}/styles.module.css +2 -2
- package/lib-next/theme/Navbar/index.js +2 -2
- package/lib-next/theme/Navbar/styles.module.css +1 -1
- package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +19 -2
- package/lib-next/theme/NavbarItem/DocNavbarItem.js +23 -9
- package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +6 -6
- package/lib-next/theme/NavbarItem/SearchNavbarItem.js +1 -6
- package/lib-next/theme/NavbarItem/index.js +1 -1
- package/lib-next/theme/NotFound.js +6 -2
- package/lib-next/theme/SearchMetadatas/index.js +1 -1
- package/lib-next/theme/Seo/index.js +0 -1
- package/lib-next/theme/SkipToContent/index.js +3 -3
- package/lib-next/theme/SkipToContent/styles.module.css +1 -3
- package/lib-next/theme/TOC/styles.module.css +1 -1
- package/lib-next/theme/ThemedImage/index.js +2 -3
- package/lib-next/theme/ThemedImage/styles.module.css +7 -0
- package/lib-next/theme/Toggle/index.js +9 -24
- package/lib-next/theme/Toggle/styles.css +103 -0
- package/lib-next/theme/Toggle/styles.module.css +0 -97
- package/lib-next/theme/UserPreferencesProvider/index.js +0 -4
- package/lib-next/theme/hooks/useHideableNavbar.js +3 -3
- package/lib-next/theme/hooks/useTabGroupChoice.js +2 -4
- package/lib-next/theme/hooks/useThemeContext.js +1 -1
- package/lib-next/theme/hooks/useUserPreferencesContext.js +1 -1
- package/lib-next/types.d.ts +10 -12
- package/lib-next/validateThemeConfig.js +3 -3
- package/package.json +18 -17
- package/src/index.ts +32 -8
- package/src/theme/AnnouncementBar/index.tsx +6 -9
- package/src/theme/AnnouncementBar/styles.module.css +6 -6
- package/src/theme/BlogListPage/index.tsx +2 -2
- package/src/theme/BlogPostItem/index.tsx +40 -24
- package/src/theme/BlogPostItem/styles.module.css +5 -1
- package/src/theme/BlogPostPage/index.tsx +4 -8
- package/src/theme/BlogPostPaginator/index.tsx +1 -1
- package/src/theme/BlogSidebar/index.tsx +12 -3
- package/src/theme/BlogSidebar/styles.module.css +4 -6
- package/src/theme/BlogTagsListPage/index.tsx +17 -22
- package/src/theme/BlogTagsPostsPage/index.tsx +33 -43
- package/src/theme/CodeBlock/index.tsx +10 -9
- package/src/theme/CodeBlock/styles.module.css +4 -7
- package/src/theme/DocItem/index.tsx +40 -40
- package/src/theme/DocItem/styles.module.css +8 -10
- package/src/theme/DocPage/index.tsx +29 -9
- package/src/theme/DocPage/styles.module.css +7 -19
- package/src/theme/DocPaginator/index.tsx +1 -1
- package/src/theme/DocSidebar/index.tsx +28 -21
- package/src/theme/DocSidebar/styles.module.css +0 -14
- package/src/theme/{DocVersionSuggestions → DocVersionBanner}/index.tsx +46 -43
- package/src/theme/Heading/index.tsx +22 -1
- package/src/theme/Heading/styles.module.css +5 -0
- package/src/theme/IconArrow/index.tsx +1 -1
- package/src/theme/IconEdit/index.tsx +3 -5
- package/src/theme/IconExternalLink/index.tsx +32 -0
- package/src/theme/IconExternalLink/styles.module.css +12 -0
- package/src/theme/IconLanguage/index.tsx +1 -1
- package/src/theme/IconMenu/index.tsx +1 -4
- package/src/theme/LastUpdated/index.tsx +34 -39
- package/src/theme/Layout/styles.css +6 -0
- package/src/theme/LayoutHead/index.tsx +5 -1
- package/src/theme/LayoutProviders/index.tsx +11 -6
- package/src/theme/Logo/index.tsx +10 -6
- package/src/theme/MDXPage/index.tsx +14 -17
- package/{lib/theme/LastUpdated → src/theme/MDXPage}/styles.module.css +2 -2
- package/src/theme/Navbar/index.tsx +2 -2
- package/src/theme/Navbar/styles.module.css +1 -1
- package/src/theme/NavbarItem/DefaultNavbarItem.tsx +15 -2
- package/src/theme/NavbarItem/DocNavbarItem.tsx +29 -10
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +7 -6
- package/src/theme/NavbarItem/SearchNavbarItem.tsx +1 -6
- package/src/theme/NavbarItem/index.tsx +1 -1
- package/src/theme/NotFound.tsx +6 -2
- package/src/theme/SearchMetadatas/index.tsx +1 -1
- package/src/theme/Seo/index.tsx +0 -1
- package/src/theme/SkipToContent/index.tsx +3 -3
- package/src/theme/SkipToContent/styles.module.css +1 -3
- package/src/theme/TOC/styles.module.css +1 -1
- package/src/theme/ThemedImage/index.tsx +3 -3
- package/src/theme/ThemedImage/styles.module.css +7 -0
- package/src/theme/Toggle/index.tsx +9 -22
- package/src/theme/Toggle/styles.css +103 -0
- package/src/theme/Toggle/styles.module.css +0 -97
- package/src/theme/UserPreferencesProvider/index.tsx +0 -5
- package/src/theme/hooks/useHideableNavbar.ts +3 -3
- package/src/theme/hooks/useTabGroupChoice.ts +2 -2
- package/src/theme/hooks/useThemeContext.ts +1 -1
- package/src/theme/hooks/useUserPreferencesContext.ts +1 -1
- package/src/types.d.ts +10 -12
- package/src/validateThemeConfig.js +3 -3
- package/update-code-translations.js +1 -0
- package/lib-next/theme/NavbarItem/styles.module.css +0 -13
- package/src/theme/NavbarItem/styles.module.css +0 -13
- package/src/theme/hooks/useAnnouncementBar.ts +0 -58
|
@@ -5,24 +5,22 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
.
|
|
9
|
-
|
|
10
|
-
margin-bottom: calc(var(--ifm-leading-desktop) * var(--ifm-leading));
|
|
8
|
+
.docItemContainer header + * {
|
|
9
|
+
margin-top: 0;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
.
|
|
14
|
-
margin: 0
|
|
15
|
-
|
|
12
|
+
.lastUpdated {
|
|
13
|
+
margin-top: 0.2rem;
|
|
14
|
+
font-style: italic;
|
|
15
|
+
font-size: smaller;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
@media only screen and (min-width: 997px) {
|
|
19
19
|
.docItemCol {
|
|
20
20
|
max-width: 75% !important;
|
|
21
21
|
}
|
|
22
|
-
}
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
padding: 0 0.3rem;
|
|
23
|
+
.lastUpdated {
|
|
24
|
+
text-align: right;
|
|
27
25
|
}
|
|
28
26
|
}
|
|
@@ -31,15 +31,36 @@ type DocPageContentProps = {
|
|
|
31
31
|
readonly children: ReactNode;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
function getSidebar({versionMetadata, currentDocRoute}) {
|
|
35
|
+
function addTrailingSlash(str: string): string {
|
|
36
|
+
return str.endsWith('/') ? str : `${str}/`;
|
|
37
|
+
}
|
|
38
|
+
function removeTrailingSlash(str: string): string {
|
|
39
|
+
return str.endsWith('/') ? str.slice(0, -1) : str;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const {permalinkToSidebar, docsSidebars} = versionMetadata;
|
|
43
|
+
|
|
44
|
+
// With/without trailingSlash, we should always be able to get the appropriate sidebar
|
|
45
|
+
// note: docs plugin permalinks currently never have trailing slashes
|
|
46
|
+
// trailingSlash is handled globally at the framework level, not plugin level
|
|
47
|
+
const sidebarName =
|
|
48
|
+
permalinkToSidebar[currentDocRoute.path] ||
|
|
49
|
+
permalinkToSidebar[addTrailingSlash(currentDocRoute.path)] ||
|
|
50
|
+
permalinkToSidebar[removeTrailingSlash(currentDocRoute.path)];
|
|
51
|
+
|
|
52
|
+
const sidebar = docsSidebars[sidebarName];
|
|
53
|
+
return {sidebar, sidebarName};
|
|
54
|
+
}
|
|
55
|
+
|
|
34
56
|
function DocPageContent({
|
|
35
57
|
currentDocRoute,
|
|
36
58
|
versionMetadata,
|
|
37
59
|
children,
|
|
38
60
|
}: DocPageContentProps): JSX.Element {
|
|
39
61
|
const {siteConfig, isClient} = useDocusaurusContext();
|
|
40
|
-
const {pluginId,
|
|
41
|
-
const sidebarName =
|
|
42
|
-
const sidebar = docsSidebars[sidebarName];
|
|
62
|
+
const {pluginId, version} = versionMetadata;
|
|
63
|
+
const {sidebarName, sidebar} = getSidebar({versionMetadata, currentDocRoute});
|
|
43
64
|
|
|
44
65
|
const [hiddenSidebarContainer, setHiddenSidebarContainer] = useState(false);
|
|
45
66
|
const [hiddenSidebar, setHiddenSidebar] = useState(false);
|
|
@@ -62,7 +83,7 @@ function DocPageContent({
|
|
|
62
83
|
}}>
|
|
63
84
|
<div className={styles.docPage}>
|
|
64
85
|
{sidebar && (
|
|
65
|
-
<
|
|
86
|
+
<aside
|
|
66
87
|
className={clsx(styles.docSidebarContainer, {
|
|
67
88
|
[styles.docSidebarContainerHidden]: hiddenSidebarContainer,
|
|
68
89
|
})}
|
|
@@ -76,8 +97,7 @@ function DocPageContent({
|
|
|
76
97
|
if (hiddenSidebarContainer) {
|
|
77
98
|
setHiddenSidebar(true);
|
|
78
99
|
}
|
|
79
|
-
}}
|
|
80
|
-
role="complementary">
|
|
100
|
+
}}>
|
|
81
101
|
<DocSidebar
|
|
82
102
|
key={
|
|
83
103
|
// Reset sidebar state on sidebar changes
|
|
@@ -115,7 +135,7 @@ function DocPageContent({
|
|
|
115
135
|
<IconArrow className={styles.expandSidebarButtonIcon} />
|
|
116
136
|
</div>
|
|
117
137
|
)}
|
|
118
|
-
</
|
|
138
|
+
</aside>
|
|
119
139
|
)}
|
|
120
140
|
<main
|
|
121
141
|
className={clsx(styles.docMainContainer, {
|
|
@@ -124,7 +144,7 @@ function DocPageContent({
|
|
|
124
144
|
})}>
|
|
125
145
|
<div
|
|
126
146
|
className={clsx(
|
|
127
|
-
'container padding-
|
|
147
|
+
'container padding-top--md padding-bottom--lg',
|
|
128
148
|
styles.docItemWrapper,
|
|
129
149
|
{
|
|
130
150
|
[styles.docItemWrapperEnhanced]: hiddenSidebarContainer,
|
|
@@ -154,7 +174,7 @@ function DocPage(props: Props): JSX.Element {
|
|
|
154
174
|
<DocPageContent
|
|
155
175
|
currentDocRoute={currentDocRoute}
|
|
156
176
|
versionMetadata={versionMetadata}>
|
|
157
|
-
{renderRoutes(docRoutes)}
|
|
177
|
+
{renderRoutes(docRoutes, {versionMetadata})}
|
|
158
178
|
</DocPageContent>
|
|
159
179
|
);
|
|
160
180
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
:root {
|
|
9
9
|
--doc-sidebar-width: 300px;
|
|
10
|
+
--doc-sidebar-hidden-width: 30px;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
:global(.docs-wrapper) {
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
.docMainContainerEnhanced {
|
|
29
|
-
max-width:
|
|
30
|
+
max-width: calc(100% - var(--doc-sidebar-hidden-width));
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
.docSidebarContainer {
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
.docSidebarContainerHidden {
|
|
42
|
-
width:
|
|
43
|
+
width: var(--doc-sidebar-hidden-width);
|
|
43
44
|
cursor: pointer;
|
|
44
45
|
}
|
|
45
46
|
|
|
@@ -72,27 +73,14 @@
|
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
.docItemWrapperEnhanced {
|
|
75
|
-
max-width: calc(
|
|
76
|
+
max-width: calc(
|
|
77
|
+
var(--ifm-container-width) + var(--doc-sidebar-width)
|
|
78
|
+
) !important;
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
@media (max-width: 996px) {
|
|
80
83
|
.docSidebarContainer {
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
@media (min-width: 997px) and (max-width: 1320px) {
|
|
86
|
-
.docItemWrapper {
|
|
87
|
-
max-width: calc(
|
|
88
|
-
var(--ifm-container-width) - var(--doc-sidebar-width) -
|
|
89
|
-
var(--ifm-spacing-horizontal) * 2
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.docItemWrapperEnhanced {
|
|
94
|
-
max-width: calc(
|
|
95
|
-
var(--ifm-container-width) - var(--ifm-spacing-horizontal) * 2
|
|
96
|
-
);
|
|
84
|
+
display: none;
|
|
97
85
|
}
|
|
98
86
|
}
|
|
@@ -7,8 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
import React, {useState, useCallback, useEffect, useRef, memo} from 'react';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
|
-
import {
|
|
11
|
-
|
|
10
|
+
import {
|
|
11
|
+
useThemeConfig,
|
|
12
|
+
isSamePath,
|
|
13
|
+
usePrevious,
|
|
14
|
+
useAnnouncementBar,
|
|
15
|
+
} from '@docusaurus/theme-common';
|
|
12
16
|
import useLockBodyScroll from '@theme/hooks/useLockBodyScroll';
|
|
13
17
|
import useWindowSize, {windowSizes} from '@theme/hooks/useWindowSize';
|
|
14
18
|
import useScrollPosition from '@theme/hooks/useScrollPosition';
|
|
@@ -18,20 +22,13 @@ import type {Props} from '@theme/DocSidebar';
|
|
|
18
22
|
import Logo from '@theme/Logo';
|
|
19
23
|
import IconArrow from '@theme/IconArrow';
|
|
20
24
|
import IconMenu from '@theme/IconMenu';
|
|
25
|
+
import IconExternalLink from '@theme/IconExternalLink';
|
|
21
26
|
import {translate} from '@docusaurus/Translate';
|
|
22
27
|
|
|
23
28
|
import styles from './styles.module.css';
|
|
24
29
|
|
|
25
30
|
const MOBILE_TOGGLE_SIZE = 24;
|
|
26
31
|
|
|
27
|
-
function usePrevious(value) {
|
|
28
|
-
const ref = useRef(value);
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
ref.current = value;
|
|
31
|
-
}, [value]);
|
|
32
|
-
return ref.current;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
32
|
const isActiveSidebarItem = (item, activePath) => {
|
|
36
33
|
if (item.type === 'link') {
|
|
37
34
|
return isSamePath(item.href, activePath);
|
|
@@ -179,7 +176,6 @@ function DocSidebarItemLink({
|
|
|
179
176
|
<Link
|
|
180
177
|
className={clsx('menu__link', {
|
|
181
178
|
'menu__link--active': isActive,
|
|
182
|
-
[styles.menuLinkExternal]: !isInternalUrl(href),
|
|
183
179
|
})}
|
|
184
180
|
to={href}
|
|
185
181
|
{...(isInternalUrl(href) && {
|
|
@@ -188,19 +184,24 @@ function DocSidebarItemLink({
|
|
|
188
184
|
onClick: onItemClick,
|
|
189
185
|
})}
|
|
190
186
|
{...props}>
|
|
191
|
-
{
|
|
187
|
+
{isInternalUrl(href) ? (
|
|
188
|
+
label
|
|
189
|
+
) : (
|
|
190
|
+
<span>
|
|
191
|
+
{label}
|
|
192
|
+
<IconExternalLink />
|
|
193
|
+
</span>
|
|
194
|
+
)}
|
|
192
195
|
</Link>
|
|
193
196
|
</li>
|
|
194
197
|
);
|
|
195
198
|
}
|
|
196
199
|
|
|
197
200
|
function useShowAnnouncementBar() {
|
|
198
|
-
const {
|
|
199
|
-
const [showAnnouncementBar, setShowAnnouncementBar] = useState(
|
|
200
|
-
!isAnnouncementBarClosed,
|
|
201
|
-
);
|
|
201
|
+
const {isClosed} = useAnnouncementBar();
|
|
202
|
+
const [showAnnouncementBar, setShowAnnouncementBar] = useState(!isClosed);
|
|
202
203
|
useScrollPosition(({scrollY}) => {
|
|
203
|
-
if (!
|
|
204
|
+
if (!isClosed) {
|
|
204
205
|
setShowAnnouncementBar(scrollY === 0);
|
|
205
206
|
}
|
|
206
207
|
});
|
|
@@ -311,7 +312,7 @@ function DocSidebar({
|
|
|
311
312
|
navbar: {hideOnScroll},
|
|
312
313
|
hideableSidebar,
|
|
313
314
|
} = useThemeConfig();
|
|
314
|
-
const {isAnnouncementBarClosed} =
|
|
315
|
+
const {isClosed: isAnnouncementBarClosed} = useAnnouncementBar();
|
|
315
316
|
|
|
316
317
|
const {
|
|
317
318
|
showResponsiveSidebar,
|
|
@@ -326,7 +327,7 @@ function DocSidebar({
|
|
|
326
327
|
[styles.sidebarHidden]: isHidden,
|
|
327
328
|
})}>
|
|
328
329
|
{hideOnScroll && <Logo tabIndex={-1} className={styles.sidebarLogo} />}
|
|
329
|
-
<
|
|
330
|
+
<nav
|
|
330
331
|
className={clsx(
|
|
331
332
|
'menu',
|
|
332
333
|
'menu--responsive',
|
|
@@ -337,11 +338,17 @@ function DocSidebar({
|
|
|
337
338
|
[styles.menuWithAnnouncementBar]:
|
|
338
339
|
!isAnnouncementBarClosed && showAnnouncementBar,
|
|
339
340
|
},
|
|
340
|
-
)}
|
|
341
|
+
)}
|
|
342
|
+
aria-label={translate({
|
|
343
|
+
id: 'theme.docs.sidebar.navAriaLabel',
|
|
344
|
+
message: 'Sidebar navigation',
|
|
345
|
+
description: 'The ARIA label for documentation menu',
|
|
346
|
+
})}>
|
|
341
347
|
<ResponsiveSidebarButton
|
|
342
348
|
responsiveSidebarOpened={showResponsiveSidebar}
|
|
343
349
|
onClick={toggleResponsiveSidebar}
|
|
344
350
|
/>
|
|
351
|
+
|
|
345
352
|
<ul className="menu__list">
|
|
346
353
|
<DocSidebarItems
|
|
347
354
|
items={sidebar}
|
|
@@ -350,7 +357,7 @@ function DocSidebar({
|
|
|
350
357
|
activePath={path}
|
|
351
358
|
/>
|
|
352
359
|
</ul>
|
|
353
|
-
</
|
|
360
|
+
</nav>
|
|
354
361
|
{hideableSidebar && <HideableSidebarButton onClick={onCollapse} />}
|
|
355
362
|
</div>
|
|
356
363
|
);
|
|
@@ -122,17 +122,3 @@
|
|
|
122
122
|
:global(.menu__list-item--collapsed) :global(.menu__list) {
|
|
123
123
|
height: 0 !important;
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
.menuLinkExternal {
|
|
127
|
-
align-items: center;
|
|
128
|
-
}
|
|
129
|
-
.menuLinkExternal:after {
|
|
130
|
-
content: '';
|
|
131
|
-
height: 1.15rem;
|
|
132
|
-
width: 1.15rem;
|
|
133
|
-
min-width: 1.15rem;
|
|
134
|
-
margin: 0 0 0 3%;
|
|
135
|
-
background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='rgba(0,0,0,0.5)' d='M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z'/%3E%3C/svg%3E")
|
|
136
|
-
no-repeat;
|
|
137
|
-
filter: var(--ifm-menu-link-sublist-icon-filter);
|
|
138
|
-
}
|
|
@@ -5,31 +5,31 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React from 'react';
|
|
8
|
+
import React, {ComponentType} from 'react';
|
|
9
9
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
10
10
|
import Link from '@docusaurus/Link';
|
|
11
11
|
import Translate from '@docusaurus/Translate';
|
|
12
|
-
import {
|
|
13
|
-
useActivePlugin,
|
|
14
|
-
useActiveVersion,
|
|
15
|
-
useDocVersionSuggestions,
|
|
16
|
-
} from '@theme/hooks/useDocs';
|
|
12
|
+
import {useActivePlugin, useDocVersionSuggestions} from '@theme/hooks/useDocs';
|
|
17
13
|
import {useDocsPreferredVersion} from '@docusaurus/theme-common';
|
|
18
14
|
|
|
15
|
+
import type {Props} from '@theme/DocVersionBanner';
|
|
16
|
+
|
|
17
|
+
type BannerLabelComponentProps = {
|
|
18
|
+
siteTitle: string;
|
|
19
|
+
versionMetadata: Props['versionMetadata'];
|
|
20
|
+
};
|
|
21
|
+
|
|
19
22
|
function UnreleasedVersionLabel({
|
|
20
23
|
siteTitle,
|
|
21
|
-
|
|
22
|
-
}: {
|
|
23
|
-
siteTitle: string;
|
|
24
|
-
versionLabel: string;
|
|
25
|
-
}) {
|
|
24
|
+
versionMetadata,
|
|
25
|
+
}: BannerLabelComponentProps) {
|
|
26
26
|
return (
|
|
27
27
|
<Translate
|
|
28
28
|
id="theme.docs.versions.unreleasedVersionLabel"
|
|
29
29
|
description="The label used to tell the user that he's browsing an unreleased doc version"
|
|
30
30
|
values={{
|
|
31
31
|
siteTitle,
|
|
32
|
-
versionLabel: <
|
|
32
|
+
versionLabel: <b>{versionMetadata.label}</b>,
|
|
33
33
|
}}>
|
|
34
34
|
{
|
|
35
35
|
'This is unreleased documentation for {siteTitle} {versionLabel} version.'
|
|
@@ -40,18 +40,15 @@ function UnreleasedVersionLabel({
|
|
|
40
40
|
|
|
41
41
|
function UnmaintainedVersionLabel({
|
|
42
42
|
siteTitle,
|
|
43
|
-
|
|
44
|
-
}: {
|
|
45
|
-
siteTitle: string;
|
|
46
|
-
versionLabel: string;
|
|
47
|
-
}) {
|
|
43
|
+
versionMetadata,
|
|
44
|
+
}: BannerLabelComponentProps) {
|
|
48
45
|
return (
|
|
49
46
|
<Translate
|
|
50
47
|
id="theme.docs.versions.unmaintainedVersionLabel"
|
|
51
48
|
description="The label used to tell the user that he's browsing an unmaintained doc version"
|
|
52
49
|
values={{
|
|
53
50
|
siteTitle,
|
|
54
|
-
versionLabel: <
|
|
51
|
+
versionLabel: <b>{versionMetadata.label}</b>,
|
|
55
52
|
}}>
|
|
56
53
|
{
|
|
57
54
|
'This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained.'
|
|
@@ -60,6 +57,20 @@ function UnmaintainedVersionLabel({
|
|
|
60
57
|
);
|
|
61
58
|
}
|
|
62
59
|
|
|
60
|
+
const BannerLabelComponents: Record<
|
|
61
|
+
Props['versionMetadata']['banner'],
|
|
62
|
+
ComponentType<BannerLabelComponentProps>
|
|
63
|
+
> = {
|
|
64
|
+
unreleased: UnreleasedVersionLabel,
|
|
65
|
+
unmaintained: UnmaintainedVersionLabel,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
function BannerLabel(props: BannerLabelComponentProps) {
|
|
69
|
+
const BannerLabelComponent =
|
|
70
|
+
BannerLabelComponents[props.versionMetadata.banner];
|
|
71
|
+
return <BannerLabelComponent {...props} />;
|
|
72
|
+
}
|
|
73
|
+
|
|
63
74
|
function LatestVersionSuggestionLabel({
|
|
64
75
|
versionLabel,
|
|
65
76
|
to,
|
|
@@ -72,11 +83,11 @@ function LatestVersionSuggestionLabel({
|
|
|
72
83
|
return (
|
|
73
84
|
<Translate
|
|
74
85
|
id="theme.docs.versions.latestVersionSuggestionLabel"
|
|
75
|
-
description="The label
|
|
86
|
+
description="The label used to tell the user to check the latest version"
|
|
76
87
|
values={{
|
|
77
88
|
versionLabel,
|
|
78
89
|
latestVersionLink: (
|
|
79
|
-
<
|
|
90
|
+
<b>
|
|
80
91
|
<Link to={to} onClick={onClick}>
|
|
81
92
|
<Translate
|
|
82
93
|
id="theme.docs.versions.latestVersionLinkLabel"
|
|
@@ -84,7 +95,7 @@ function LatestVersionSuggestionLabel({
|
|
|
84
95
|
latest version
|
|
85
96
|
</Translate>
|
|
86
97
|
</Link>
|
|
87
|
-
</
|
|
98
|
+
</b>
|
|
88
99
|
),
|
|
89
100
|
}}>
|
|
90
101
|
{
|
|
@@ -94,28 +105,22 @@ function LatestVersionSuggestionLabel({
|
|
|
94
105
|
);
|
|
95
106
|
}
|
|
96
107
|
|
|
97
|
-
|
|
98
|
-
version.docs.find((doc) => doc.id === version.mainDocId);
|
|
99
|
-
|
|
100
|
-
function DocVersionSuggestions(): JSX.Element {
|
|
108
|
+
function DocVersionBannerEnabled({versionMetadata}: Props): JSX.Element {
|
|
101
109
|
const {
|
|
102
110
|
siteConfig: {title: siteTitle},
|
|
103
111
|
} = useDocusaurusContext();
|
|
104
112
|
const {pluginId} = useActivePlugin({failfast: true});
|
|
105
113
|
|
|
114
|
+
const getVersionMainDoc = (version) =>
|
|
115
|
+
version.docs.find((doc) => doc.id === version.mainDocId);
|
|
116
|
+
|
|
106
117
|
const {savePreferredVersionName} = useDocsPreferredVersion(pluginId);
|
|
107
118
|
|
|
108
|
-
const activeVersion = useActiveVersion(pluginId);
|
|
109
119
|
const {
|
|
110
120
|
latestDocSuggestion,
|
|
111
121
|
latestVersionSuggestion,
|
|
112
122
|
} = useDocVersionSuggestions(pluginId);
|
|
113
123
|
|
|
114
|
-
// No suggestion to be made
|
|
115
|
-
if (!latestVersionSuggestion) {
|
|
116
|
-
return <></>;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
124
|
// try to link to same doc in latest version (not always possible)
|
|
120
125
|
// fallback to main doc of latest version
|
|
121
126
|
const latestVersionSuggestedDoc =
|
|
@@ -124,17 +129,7 @@ function DocVersionSuggestions(): JSX.Element {
|
|
|
124
129
|
return (
|
|
125
130
|
<div className="alert alert--warning margin-bottom--md" role="alert">
|
|
126
131
|
<div>
|
|
127
|
-
{
|
|
128
|
-
<UnreleasedVersionLabel
|
|
129
|
-
siteTitle={siteTitle}
|
|
130
|
-
versionLabel={activeVersion.label}
|
|
131
|
-
/>
|
|
132
|
-
) : (
|
|
133
|
-
<UnmaintainedVersionLabel
|
|
134
|
-
siteTitle={siteTitle}
|
|
135
|
-
versionLabel={activeVersion.label}
|
|
136
|
-
/>
|
|
137
|
-
)}
|
|
132
|
+
<BannerLabel siteTitle={siteTitle} versionMetadata={versionMetadata} />
|
|
138
133
|
</div>
|
|
139
134
|
<div className="margin-top--md">
|
|
140
135
|
<LatestVersionSuggestionLabel
|
|
@@ -147,4 +142,12 @@ function DocVersionSuggestions(): JSX.Element {
|
|
|
147
142
|
);
|
|
148
143
|
}
|
|
149
144
|
|
|
150
|
-
|
|
145
|
+
function DocVersionBanner({versionMetadata}: Props): JSX.Element {
|
|
146
|
+
if (versionMetadata.banner === 'none') {
|
|
147
|
+
return <></>;
|
|
148
|
+
} else {
|
|
149
|
+
return <DocVersionBannerEnabled versionMetadata={versionMetadata} />;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export default DocVersionBanner;
|
|
@@ -16,7 +16,24 @@ import {useThemeConfig} from '@docusaurus/theme-common';
|
|
|
16
16
|
import './styles.css';
|
|
17
17
|
import styles from './styles.module.css';
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
type HeadingComponent = (props: Props) => JSX.Element;
|
|
20
|
+
|
|
21
|
+
export const MainHeading: HeadingComponent = function MainHeading({...props}) {
|
|
22
|
+
return (
|
|
23
|
+
<header>
|
|
24
|
+
<h1
|
|
25
|
+
{...props}
|
|
26
|
+
id={undefined} // h1 headings do not need an id because they don't appear in the TOC
|
|
27
|
+
className={styles.h1Heading}>
|
|
28
|
+
{props.children}
|
|
29
|
+
</h1>
|
|
30
|
+
</header>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const createAnchorHeading = (
|
|
35
|
+
Tag: HeadingType,
|
|
36
|
+
): ((props: Props) => JSX.Element) =>
|
|
20
37
|
function TargetComponent({id, ...props}) {
|
|
21
38
|
const {
|
|
22
39
|
navbar: {hideOnScroll},
|
|
@@ -51,4 +68,8 @@ const Heading = (Tag: HeadingType): ((props: Props) => JSX.Element) =>
|
|
|
51
68
|
);
|
|
52
69
|
};
|
|
53
70
|
|
|
71
|
+
const Heading = (headingType: HeadingType): ((props: Props) => JSX.Element) => {
|
|
72
|
+
return headingType === 'h1' ? MainHeading : createAnchorHeading(headingType);
|
|
73
|
+
};
|
|
74
|
+
|
|
54
75
|
export default Heading;
|
|
@@ -10,7 +10,7 @@ import type {Props} from '@theme/IconArrow';
|
|
|
10
10
|
|
|
11
11
|
const IconArrow = (props: Props): JSX.Element => {
|
|
12
12
|
return (
|
|
13
|
-
<svg width="20" height="20"
|
|
13
|
+
<svg width="20" height="20" aria-hidden="true" {...props}>
|
|
14
14
|
<g fill="#7a7a7a">
|
|
15
15
|
<path d="M9.992 10.023c0 .2-.062.399-.172.547l-4.996 7.492a.982.982 0 01-.828.454H1c-.55 0-1-.453-1-1 0-.2.059-.403.168-.551l4.629-6.942L.168 3.078A.939.939 0 010 2.528c0-.548.45-.997 1-.997h2.996c.352 0 .649.18.828.45L9.82 9.472c.11.148.172.347.172.55zm0 0" />
|
|
16
16
|
<path d="M19.98 10.023c0 .2-.058.399-.168.547l-4.996 7.492a.987.987 0 01-.828.454h-3c-.547 0-.996-.453-.996-1 0-.2.059-.403.168-.551l4.625-6.942-4.625-6.945a.939.939 0 01-.168-.55 1 1 0 01.996-.997h3c.348 0 .649.18.828.45l4.996 7.492c.11.148.168.347.168.55zm0 0" />
|
|
@@ -16,13 +16,11 @@ const IconEdit = ({className, ...restProps}: Props): JSX.Element => {
|
|
|
16
16
|
return (
|
|
17
17
|
<svg
|
|
18
18
|
fill="currentColor"
|
|
19
|
-
height="
|
|
20
|
-
width="
|
|
21
|
-
preserveAspectRatio="xMidYMid meet"
|
|
22
|
-
role="img"
|
|
19
|
+
height="20"
|
|
20
|
+
width="20"
|
|
23
21
|
viewBox="0 0 40 40"
|
|
24
22
|
className={clsx(styles.iconEdit, className)}
|
|
25
|
-
aria-
|
|
23
|
+
aria-hidden="true"
|
|
26
24
|
{...restProps}>
|
|
27
25
|
<g>
|
|
28
26
|
<path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z" />
|
|
@@ -0,0 +1,32 @@
|
|
|
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 type {Props} from '@theme/IconExternalLink';
|
|
10
|
+
|
|
11
|
+
import styles from './styles.module.css';
|
|
12
|
+
|
|
13
|
+
const IconExternalLink = ({
|
|
14
|
+
width = 13.5,
|
|
15
|
+
height = 13.5,
|
|
16
|
+
}: Props): JSX.Element => {
|
|
17
|
+
return (
|
|
18
|
+
<svg
|
|
19
|
+
width={width}
|
|
20
|
+
height={height}
|
|
21
|
+
aria-hidden="true"
|
|
22
|
+
viewBox="0 0 24 24"
|
|
23
|
+
className={styles.iconExternalLink}>
|
|
24
|
+
<path
|
|
25
|
+
fill="currentColor"
|
|
26
|
+
d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"
|
|
27
|
+
/>
|
|
28
|
+
</svg>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default IconExternalLink;
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
.iconExternalLink {
|
|
9
|
+
margin-left: 0.3rem;
|
|
10
|
+
position: relative;
|
|
11
|
+
top: 1px;
|
|
12
|
+
}
|
|
@@ -16,15 +16,12 @@ const IconMenu = ({
|
|
|
16
16
|
}: Props): JSX.Element => {
|
|
17
17
|
return (
|
|
18
18
|
<svg
|
|
19
|
-
aria-label="Menu"
|
|
20
19
|
className={className}
|
|
21
20
|
width={width}
|
|
22
21
|
height={height}
|
|
23
22
|
viewBox="0 0 30 30"
|
|
24
|
-
|
|
25
|
-
focusable="false"
|
|
23
|
+
aria-hidden="true"
|
|
26
24
|
{...restProps}>
|
|
27
|
-
<title>Menu</title>
|
|
28
25
|
<path
|
|
29
26
|
stroke="currentColor"
|
|
30
27
|
strokeLinecap="round"
|