@docusaurus/theme-classic 2.0.0-beta.18 → 2.0.0-beta.19
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/admonitions.css +4 -0
- package/lib/default.css +3038 -0
- package/lib/getSwizzleConfig.js +9 -2
- package/lib/index.js +4 -4
- package/lib/nprogress.css +41 -0
- package/lib/nprogress.js +46 -0
- package/lib/theme-classic.d.ts +315 -33
- package/lib/validateThemeConfig.js +72 -14
- package/lib-next/theme/BackToTopButton/index.js +6 -102
- package/lib-next/theme/BlogLayout/index.js +1 -5
- package/lib-next/theme/BlogListPaginator/index.js +25 -28
- package/lib-next/theme/BlogPostAuthor/index.js +3 -6
- package/lib-next/theme/BlogPostItem/styles.module.css +9 -0
- package/lib-next/theme/BlogPostPaginator/index.js +25 -28
- package/lib-next/theme/BlogSidebar/Desktop/index.js +41 -0
- package/lib-next/theme/BlogSidebar/{styles.module.css → Desktop/styles.module.css} +1 -2
- package/lib-next/theme/BlogSidebar/Mobile/index.js +36 -0
- package/lib-next/theme/BlogSidebar/index.js +11 -31
- package/lib-next/theme/BlogTagsListPage/index.js +2 -3
- package/lib-next/theme/BlogTagsPostsPage/index.js +4 -6
- package/lib-next/theme/CodeBlock/Container/index.js +29 -0
- package/lib-next/theme/CodeBlock/Container/styles.module.css +14 -0
- package/lib-next/theme/CodeBlock/Content/Element.js +23 -0
- package/lib-next/theme/CodeBlock/Content/String.js +104 -0
- package/{src/theme/CodeBlock → lib-next/theme/CodeBlock/Content}/styles.module.css +39 -9
- package/lib-next/theme/CodeBlock/CopyButton/index.js +3 -2
- package/lib-next/theme/CodeBlock/CopyButton/styles.module.css +0 -19
- package/lib-next/theme/CodeBlock/Line/index.js +49 -0
- package/lib-next/theme/CodeBlock/Line/styles.module.css +51 -0
- package/lib-next/theme/CodeBlock/WordWrapButton/index.js +40 -0
- package/lib-next/theme/CodeBlock/WordWrapButton/styles.module.css +15 -0
- package/lib-next/theme/CodeBlock/index.js +27 -133
- package/lib-next/theme/Details/index.js +1 -1
- package/lib-next/theme/DocBreadcrumbs/index.js +50 -23
- package/lib-next/theme/DocBreadcrumbs/styles.module.css +8 -0
- package/lib-next/theme/DocCardList/index.js +6 -4
- package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +3 -3
- package/lib-next/theme/DocCategoryGeneratedIndexPage/styles.module.css +8 -0
- package/lib-next/theme/DocItem/index.js +1 -1
- package/lib-next/theme/DocItem/styles.module.css +6 -0
- package/lib-next/theme/DocPage/Layout/Main/index.js +29 -0
- package/lib-next/theme/DocPage/Layout/Main/styles.module.css +28 -0
- package/lib-next/theme/DocPage/Layout/Sidebar/ExpandButton/index.js +34 -0
- package/lib-next/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +33 -0
- package/lib-next/theme/DocPage/Layout/Sidebar/index.js +68 -0
- package/lib-next/theme/DocPage/Layout/Sidebar/index.module.css +32 -0
- package/lib-next/theme/DocPage/Layout/index.js +34 -0
- package/lib-next/theme/{BlogPostAuthor/styles.module.css → DocPage/Layout/index.module.css} +6 -3
- package/lib-next/theme/DocPage/index.js +28 -146
- package/lib-next/theme/DocPaginator/index.js +25 -28
- package/lib-next/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +11 -9
- package/lib-next/theme/DocSidebar/Desktop/Content/styles.module.css +6 -0
- package/lib-next/theme/DocSidebar/Desktop/index.js +4 -2
- package/lib-next/theme/DocSidebarItem/Category.js +197 -0
- package/lib-next/theme/DocSidebarItem/Html.js +27 -0
- package/{src/theme/DocSidebarItem/styles.module.css → lib-next/theme/DocSidebarItem/Html.module.css} +0 -4
- package/lib-next/theme/DocSidebarItem/Link.js +53 -0
- package/{src/theme/MDXComponents/Ul.module.css → lib-next/theme/DocSidebarItem/Link.module.css} +2 -3
- package/lib-next/theme/DocSidebarItem/index.js +4 -246
- package/lib-next/theme/DocSidebarItems/index.js +1 -6
- package/lib-next/theme/DocTagDocListPage/index.js +3 -3
- package/lib-next/theme/DocVersionBanner/index.js +2 -2
- package/lib-next/theme/Footer/Links/MultiColumn/index.js +1 -1
- package/lib-next/theme/Heading/index.js +4 -20
- package/lib-next/theme/IconHome/index.js +17 -0
- package/lib-next/theme/LastUpdated/index.js +1 -0
- package/lib-next/theme/Layout/index.js +1 -1
- package/lib-next/theme/MDXComponents/Ul.js +2 -4
- package/lib-next/theme/Navbar/Content/index.js +6 -1
- package/lib-next/theme/Navbar/Logo/index.js +1 -1
- package/lib-next/theme/Navbar/Search/index.js +11 -0
- package/lib-next/theme/Navbar/Search/styles.module.css +20 -0
- package/lib-next/theme/NavbarItem/ComponentTypes.js +27 -0
- package/lib-next/theme/NavbarItem/DocNavbarItem.js +11 -28
- package/lib-next/theme/NavbarItem/DocSidebarNavbarItem.js +10 -42
- package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +25 -29
- package/lib-next/theme/NavbarItem/DocsVersionNavbarItem.js +2 -9
- package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +4 -1
- package/lib-next/theme/NavbarItem/HtmlNavbarItem.js +30 -0
- package/lib-next/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +5 -10
- package/lib-next/theme/NavbarItem/NavbarNavLink.js +49 -31
- package/lib-next/theme/NavbarItem/SearchNavbarItem.js +6 -1
- package/lib-next/theme/NavbarItem/index.js +4 -23
- package/lib-next/theme/NavbarItem/utils.js +2 -1
- package/lib-next/theme/PaginatorNavLink/index.js +8 -2
- package/lib-next/theme/SiteMetadata/index.js +8 -7
- package/lib-next/theme/SkipToContent/index.js +3 -29
- package/lib-next/theme/TOCCollapsible/CollapseButton.js +29 -0
- package/{src/theme/TOCCollapsible/styles.module.css → lib-next/theme/TOCCollapsible/CollapseButton.module.css} +1 -22
- package/lib-next/theme/TOCCollapsible/index.js +3 -13
- package/lib-next/theme/TOCCollapsible/index.module.css +31 -0
- package/lib-next/theme/TOCItems/Tree.js +40 -0
- package/lib-next/theme/TOCItems/index.js +3 -34
- package/lib-next/theme/TabItem/index.js +3 -1
- package/lib-next/theme/{MDXComponents/Ul.module.css → TabItem/styles.module.css} +2 -3
- package/lib-next/theme/Tabs/__tests__/index.test.js +3 -3
- package/lib-next/theme/Tabs/index.js +3 -3
- package/lib-next/theme/Tabs/styles.module.css +4 -0
- package/lib-next/theme/Tag/index.js +2 -3
- package/lib-next/theme/TagsListInline/index.js +1 -1
- package/package.json +23 -18
- package/src/admonitions.css +4 -0
- package/src/getSwizzleConfig.ts +10 -2
- package/src/index.ts +4 -3
- package/src/nprogress.css +41 -0
- package/src/nprogress.ts +31 -0
- package/src/theme/BackToTopButton/index.tsx +5 -112
- package/src/theme/BlogLayout/index.tsx +1 -5
- package/src/theme/BlogListPaginator/index.tsx +25 -28
- package/src/theme/BlogPostAuthor/index.tsx +3 -7
- package/src/theme/BlogPostItem/styles.module.css +9 -0
- package/src/theme/BlogPostPaginator/index.tsx +25 -28
- package/src/theme/BlogSidebar/Desktop/index.tsx +45 -0
- package/src/theme/BlogSidebar/{styles.module.css → Desktop/styles.module.css} +1 -2
- package/src/theme/BlogSidebar/Mobile/index.tsx +38 -0
- package/src/theme/BlogSidebar/index.tsx +10 -31
- package/src/theme/BlogTagsListPage/index.tsx +2 -3
- package/src/theme/BlogTagsPostsPage/index.tsx +8 -5
- package/src/theme/CodeBlock/Container/index.tsx +35 -0
- package/src/theme/CodeBlock/Container/styles.module.css +14 -0
- package/src/theme/CodeBlock/Content/Element.tsx +30 -0
- package/src/theme/CodeBlock/Content/String.tsx +111 -0
- package/{lib-next/theme/CodeBlock → src/theme/CodeBlock/Content}/styles.module.css +39 -9
- package/src/theme/CodeBlock/CopyButton/index.tsx +3 -2
- package/src/theme/CodeBlock/CopyButton/styles.module.css +0 -19
- package/src/theme/CodeBlock/Line/index.tsx +48 -0
- package/src/theme/CodeBlock/Line/styles.module.css +51 -0
- package/src/theme/CodeBlock/WordWrapButton/index.tsx +49 -0
- package/src/theme/CodeBlock/WordWrapButton/styles.module.css +15 -0
- package/src/theme/CodeBlock/index.tsx +29 -133
- package/src/theme/Details/index.tsx +1 -1
- package/src/theme/DocBreadcrumbs/index.tsx +50 -20
- package/src/theme/DocBreadcrumbs/styles.module.css +8 -0
- package/src/theme/DocCardList/index.tsx +5 -7
- package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +3 -3
- package/src/theme/DocCategoryGeneratedIndexPage/styles.module.css +8 -0
- package/src/theme/DocItem/index.tsx +1 -1
- package/src/theme/DocItem/styles.module.css +6 -0
- package/src/theme/DocPage/Layout/Main/index.tsx +37 -0
- package/src/theme/DocPage/Layout/Main/styles.module.css +28 -0
- package/src/theme/DocPage/Layout/Sidebar/ExpandButton/index.tsx +40 -0
- package/src/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +33 -0
- package/src/theme/DocPage/Layout/Sidebar/index.module.css +32 -0
- package/src/theme/DocPage/Layout/Sidebar/index.tsx +74 -0
- package/src/theme/{BlogPostAuthor/styles.module.css → DocPage/Layout/index.module.css} +6 -3
- package/src/theme/DocPage/Layout/index.tsx +39 -0
- package/src/theme/DocPage/index.tsx +28 -157
- package/src/theme/DocPaginator/index.tsx +25 -28
- package/src/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +11 -9
- package/src/theme/DocSidebar/Desktop/Content/styles.module.css +6 -0
- package/src/theme/DocSidebar/Desktop/index.tsx +4 -2
- package/src/theme/DocSidebarItem/Category.tsx +210 -0
- package/{lib-next/theme/DocSidebarItem/styles.module.css → src/theme/DocSidebarItem/Html.module.css} +0 -4
- package/src/theme/DocSidebarItem/Html.tsx +34 -0
- package/src/theme/DocSidebarItem/Link.module.css +10 -0
- package/src/theme/DocSidebarItem/Link.tsx +58 -0
- package/src/theme/DocSidebarItem/index.tsx +4 -259
- package/src/theme/DocSidebarItems/index.tsx +1 -6
- package/src/theme/DocTagDocListPage/index.tsx +3 -4
- package/src/theme/DocVersionBanner/index.tsx +2 -2
- package/src/theme/Footer/Links/MultiColumn/index.tsx +1 -1
- package/src/theme/Heading/index.tsx +4 -18
- package/src/theme/IconHome/index.tsx +20 -0
- package/src/theme/LastUpdated/index.tsx +1 -0
- package/src/theme/Layout/index.tsx +1 -1
- package/src/theme/MDXComponents/Details.tsx +2 -3
- package/src/theme/MDXComponents/Ul.tsx +2 -6
- package/src/theme/Navbar/Content/index.tsx +6 -1
- package/src/theme/Navbar/Logo/index.tsx +1 -1
- package/src/theme/Navbar/Search/index.tsx +15 -0
- package/src/theme/Navbar/Search/styles.module.css +20 -0
- package/src/theme/NavbarItem/ComponentTypes.tsx +32 -0
- package/src/theme/NavbarItem/DocNavbarItem.tsx +13 -32
- package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +9 -49
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +26 -33
- package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +3 -10
- package/src/theme/NavbarItem/DropdownNavbarItem.tsx +4 -1
- package/src/theme/NavbarItem/HtmlNavbarItem.tsx +32 -0
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +5 -9
- package/src/theme/NavbarItem/NavbarNavLink.tsx +41 -25
- package/src/theme/NavbarItem/SearchNavbarItem.tsx +6 -1
- package/src/theme/NavbarItem/index.tsx +9 -38
- package/src/theme/NavbarItem/utils.ts +5 -2
- package/src/theme/PaginatorNavLink/index.tsx +8 -2
- package/src/theme/SiteMetadata/index.tsx +8 -8
- package/src/theme/SkipToContent/index.tsx +3 -29
- package/{lib-next/theme/TOCCollapsible/styles.module.css → src/theme/TOCCollapsible/CollapseButton.module.css} +1 -22
- package/src/theme/TOCCollapsible/CollapseButton.tsx +35 -0
- package/src/theme/TOCCollapsible/index.module.css +31 -0
- package/src/theme/TOCCollapsible/index.tsx +3 -14
- package/src/theme/TOCItems/Tree.tsx +46 -0
- package/src/theme/TOCItems/index.tsx +2 -41
- package/src/theme/TabItem/index.tsx +7 -1
- package/src/theme/TabItem/styles.module.css +10 -0
- package/src/theme/Tabs/index.tsx +3 -3
- package/src/theme/Tabs/styles.module.css +4 -0
- package/src/theme/Tag/index.tsx +2 -4
- package/src/theme/TagsListInline/index.tsx +1 -1
- package/src/theme-classic.d.ts +315 -33
- package/src/validateThemeConfig.ts +80 -13
- package/lib/types.d.ts +0 -11
- package/lib-next/theme/DocPage/styles.module.css +0 -82
- package/src/theme/DocPage/styles.module.css +0 -82
- package/src/types.d.ts +0 -11
|
@@ -4,26 +4,10 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
usePrevious,
|
|
12
|
-
Collapsible,
|
|
13
|
-
useCollapsible,
|
|
14
|
-
findFirstCategoryLink,
|
|
15
|
-
ThemeClassNames,
|
|
16
|
-
useThemeConfig,
|
|
17
|
-
useDocSidebarItemsExpandedState,
|
|
18
|
-
isSamePath,
|
|
19
|
-
} from '@docusaurus/theme-common';
|
|
20
|
-
import Link from '@docusaurus/Link';
|
|
21
|
-
import isInternalUrl from '@docusaurus/isInternalUrl';
|
|
22
|
-
import {translate} from '@docusaurus/Translate';
|
|
23
|
-
import IconExternalLink from '@theme/IconExternalLink';
|
|
24
|
-
import DocSidebarItems from '@theme/DocSidebarItems';
|
|
25
|
-
import styles from './styles.module.css';
|
|
26
|
-
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import DocSidebarItemCategory from '@theme/DocSidebarItem/Category';
|
|
9
|
+
import DocSidebarItemLink from '@theme/DocSidebarItem/Link';
|
|
10
|
+
import DocSidebarItemHtml from '@theme/DocSidebarItem/Html';
|
|
27
11
|
export default function DocSidebarItem({item, ...props}) {
|
|
28
12
|
switch (item.type) {
|
|
29
13
|
case 'category':
|
|
@@ -36,230 +20,4 @@ export default function DocSidebarItem({item, ...props}) {
|
|
|
36
20
|
default:
|
|
37
21
|
return <DocSidebarItemLink item={item} {...props} />;
|
|
38
22
|
}
|
|
39
|
-
} // If we navigate to a category and it becomes active, it should automatically
|
|
40
|
-
// expand itself
|
|
41
|
-
|
|
42
|
-
function useAutoExpandActiveCategory({isActive, collapsed, setCollapsed}) {
|
|
43
|
-
const wasActive = usePrevious(isActive);
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
const justBecameActive = isActive && !wasActive;
|
|
46
|
-
|
|
47
|
-
if (justBecameActive && collapsed) {
|
|
48
|
-
setCollapsed(false);
|
|
49
|
-
}
|
|
50
|
-
}, [isActive, wasActive, collapsed, setCollapsed]);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* When a collapsible category has no link, we still link it to its first child
|
|
54
|
-
* during SSR as a temporary fallback. This allows to be able to navigate inside
|
|
55
|
-
* the category even when JS fails to load, is delayed or simply disabled
|
|
56
|
-
* React hydration becomes an optional progressive enhancement
|
|
57
|
-
* see https://github.com/facebookincubator/infima/issues/36#issuecomment-772543188
|
|
58
|
-
* see https://github.com/facebook/docusaurus/issues/3030
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
function useCategoryHrefWithSSRFallback(item) {
|
|
62
|
-
const isBrowser = useIsBrowser();
|
|
63
|
-
return useMemo(() => {
|
|
64
|
-
if (item.href) {
|
|
65
|
-
return item.href;
|
|
66
|
-
} // In these cases, it's not necessary to render a fallback
|
|
67
|
-
// We skip the "findFirstCategoryLink" computation
|
|
68
|
-
|
|
69
|
-
if (isBrowser || !item.collapsible) {
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return findFirstCategoryLink(item);
|
|
74
|
-
}, [item, isBrowser]);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function DocSidebarItemCategory({
|
|
78
|
-
item,
|
|
79
|
-
onItemClick,
|
|
80
|
-
activePath,
|
|
81
|
-
level,
|
|
82
|
-
index,
|
|
83
|
-
...props
|
|
84
|
-
}) {
|
|
85
|
-
const {items, label, collapsible, className, href} = item;
|
|
86
|
-
const hrefWithSSRFallback = useCategoryHrefWithSSRFallback(item);
|
|
87
|
-
const isActive = isActiveSidebarItem(item, activePath);
|
|
88
|
-
const isCurrentPage = isSamePath(href, activePath);
|
|
89
|
-
const {collapsed, setCollapsed} = useCollapsible({
|
|
90
|
-
// active categories are always initialized as expanded
|
|
91
|
-
// the default (item.collapsed) is only used for non-active categories
|
|
92
|
-
initialState: () => {
|
|
93
|
-
if (!collapsible) {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return isActive ? false : item.collapsed;
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
useAutoExpandActiveCategory({
|
|
101
|
-
isActive,
|
|
102
|
-
collapsed,
|
|
103
|
-
setCollapsed,
|
|
104
|
-
});
|
|
105
|
-
const {expandedItem, setExpandedItem} = useDocSidebarItemsExpandedState();
|
|
106
|
-
|
|
107
|
-
function updateCollapsed(toCollapsed = !collapsed) {
|
|
108
|
-
setExpandedItem(toCollapsed ? null : index);
|
|
109
|
-
setCollapsed(toCollapsed);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const {autoCollapseSidebarCategories} = useThemeConfig();
|
|
113
|
-
useEffect(() => {
|
|
114
|
-
if (
|
|
115
|
-
collapsible &&
|
|
116
|
-
expandedItem &&
|
|
117
|
-
expandedItem !== index &&
|
|
118
|
-
autoCollapseSidebarCategories
|
|
119
|
-
) {
|
|
120
|
-
setCollapsed(true);
|
|
121
|
-
}
|
|
122
|
-
}, [
|
|
123
|
-
collapsible,
|
|
124
|
-
expandedItem,
|
|
125
|
-
index,
|
|
126
|
-
setCollapsed,
|
|
127
|
-
autoCollapseSidebarCategories,
|
|
128
|
-
]);
|
|
129
|
-
return (
|
|
130
|
-
<li
|
|
131
|
-
className={clsx(
|
|
132
|
-
ThemeClassNames.docs.docSidebarItemCategory,
|
|
133
|
-
ThemeClassNames.docs.docSidebarItemCategoryLevel(level),
|
|
134
|
-
'menu__list-item',
|
|
135
|
-
{
|
|
136
|
-
'menu__list-item--collapsed': collapsed,
|
|
137
|
-
},
|
|
138
|
-
className,
|
|
139
|
-
)}>
|
|
140
|
-
<div
|
|
141
|
-
className={clsx('menu__list-item-collapsible', {
|
|
142
|
-
'menu__list-item-collapsible--active': isCurrentPage,
|
|
143
|
-
})}>
|
|
144
|
-
<Link
|
|
145
|
-
className={clsx('menu__link', {
|
|
146
|
-
'menu__link--sublist': collapsible,
|
|
147
|
-
'menu__link--sublist-caret': !href,
|
|
148
|
-
'menu__link--active': isActive,
|
|
149
|
-
})}
|
|
150
|
-
onClick={
|
|
151
|
-
collapsible
|
|
152
|
-
? (e) => {
|
|
153
|
-
onItemClick?.(item);
|
|
154
|
-
|
|
155
|
-
if (href) {
|
|
156
|
-
updateCollapsed(false);
|
|
157
|
-
} else {
|
|
158
|
-
e.preventDefault();
|
|
159
|
-
updateCollapsed();
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
: () => {
|
|
163
|
-
onItemClick?.(item);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
aria-current={isCurrentPage ? 'page' : undefined}
|
|
167
|
-
aria-expanded={collapsible ? !collapsed : undefined}
|
|
168
|
-
href={collapsible ? hrefWithSSRFallback ?? '#' : hrefWithSSRFallback}
|
|
169
|
-
{...props}>
|
|
170
|
-
{label}
|
|
171
|
-
</Link>
|
|
172
|
-
{href && collapsible && (
|
|
173
|
-
<button
|
|
174
|
-
aria-label={translate(
|
|
175
|
-
{
|
|
176
|
-
id: 'theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel',
|
|
177
|
-
message: "Toggle the collapsible sidebar category '{label}'",
|
|
178
|
-
description:
|
|
179
|
-
'The ARIA label to toggle the collapsible sidebar category',
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
label,
|
|
183
|
-
},
|
|
184
|
-
)}
|
|
185
|
-
type="button"
|
|
186
|
-
className="clean-btn menu__caret"
|
|
187
|
-
onClick={(e) => {
|
|
188
|
-
e.preventDefault();
|
|
189
|
-
updateCollapsed();
|
|
190
|
-
}}
|
|
191
|
-
/>
|
|
192
|
-
)}
|
|
193
|
-
</div>
|
|
194
|
-
|
|
195
|
-
<Collapsible lazy as="ul" className="menu__list" collapsed={collapsed}>
|
|
196
|
-
<DocSidebarItems
|
|
197
|
-
items={items}
|
|
198
|
-
tabIndex={collapsed ? -1 : 0}
|
|
199
|
-
onItemClick={onItemClick}
|
|
200
|
-
activePath={activePath}
|
|
201
|
-
level={level + 1}
|
|
202
|
-
/>
|
|
203
|
-
</Collapsible>
|
|
204
|
-
</li>
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function DocSidebarItemHtml({item, level, index}) {
|
|
209
|
-
const {value, defaultStyle, className} = item;
|
|
210
|
-
return (
|
|
211
|
-
<li
|
|
212
|
-
className={clsx(
|
|
213
|
-
ThemeClassNames.docs.docSidebarItemLink,
|
|
214
|
-
ThemeClassNames.docs.docSidebarItemLinkLevel(level),
|
|
215
|
-
defaultStyle && `${styles.menuHtmlItem} menu__list-item`,
|
|
216
|
-
className,
|
|
217
|
-
)}
|
|
218
|
-
key={index} // eslint-disable-next-line react/no-danger
|
|
219
|
-
dangerouslySetInnerHTML={{
|
|
220
|
-
__html: value,
|
|
221
|
-
}}
|
|
222
|
-
/>
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function DocSidebarItemLink({
|
|
227
|
-
item,
|
|
228
|
-
onItemClick,
|
|
229
|
-
activePath,
|
|
230
|
-
level,
|
|
231
|
-
index,
|
|
232
|
-
...props
|
|
233
|
-
}) {
|
|
234
|
-
const {href, label, className} = item;
|
|
235
|
-
const isActive = isActiveSidebarItem(item, activePath);
|
|
236
|
-
const isInternalLink = isInternalUrl(href);
|
|
237
|
-
return (
|
|
238
|
-
<li
|
|
239
|
-
className={clsx(
|
|
240
|
-
ThemeClassNames.docs.docSidebarItemLink,
|
|
241
|
-
ThemeClassNames.docs.docSidebarItemLinkLevel(level),
|
|
242
|
-
'menu__list-item',
|
|
243
|
-
className,
|
|
244
|
-
)}
|
|
245
|
-
key={label}>
|
|
246
|
-
<Link
|
|
247
|
-
className={clsx(
|
|
248
|
-
'menu__link',
|
|
249
|
-
!isInternalLink && styles.menuExternalLink,
|
|
250
|
-
{
|
|
251
|
-
'menu__link--active': isActive,
|
|
252
|
-
},
|
|
253
|
-
)}
|
|
254
|
-
aria-current={isActive ? 'page' : undefined}
|
|
255
|
-
to={href}
|
|
256
|
-
{...(isInternalLink && {
|
|
257
|
-
onClick: onItemClick ? () => onItemClick(item) : undefined,
|
|
258
|
-
})}
|
|
259
|
-
{...props}>
|
|
260
|
-
{label}
|
|
261
|
-
{!isInternalLink && <IconExternalLink />}
|
|
262
|
-
</Link>
|
|
263
|
-
</li>
|
|
264
|
-
);
|
|
265
23
|
}
|
|
@@ -14,12 +14,7 @@ function DocSidebarItems({items, ...props}) {
|
|
|
14
14
|
return (
|
|
15
15
|
<DocSidebarItemsExpandedStateProvider>
|
|
16
16
|
{items.map((item, index) => (
|
|
17
|
-
<DocSidebarItem
|
|
18
|
-
key={index} // sidebar is static, the index does not change
|
|
19
|
-
item={item}
|
|
20
|
-
index={index}
|
|
21
|
-
{...props}
|
|
22
|
-
/>
|
|
17
|
+
<DocSidebarItem key={index} item={item} index={index} {...props} />
|
|
23
18
|
))}
|
|
24
19
|
</DocSidebarItemsExpandedStateProvider>
|
|
25
20
|
);
|
|
@@ -56,8 +56,8 @@ export default function DocTagDocListPage({tag}) {
|
|
|
56
56
|
message: '{nDocsTagged} with "{tagName}"',
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
|
-
nDocsTagged: nDocsTaggedPlural(tag.
|
|
60
|
-
tagName: tag.
|
|
59
|
+
nDocsTagged: nDocsTaggedPlural(tag.count),
|
|
60
|
+
tagName: tag.label,
|
|
61
61
|
},
|
|
62
62
|
);
|
|
63
63
|
return (
|
|
@@ -83,7 +83,7 @@ export default function DocTagDocListPage({tag}) {
|
|
|
83
83
|
</Link>
|
|
84
84
|
</header>
|
|
85
85
|
<section className="margin-vert--lg">
|
|
86
|
-
{tag.
|
|
86
|
+
{tag.items.map((doc) => (
|
|
87
87
|
<DocItem key={doc.id} doc={doc} />
|
|
88
88
|
))}
|
|
89
89
|
</section>
|
|
@@ -101,8 +101,8 @@ function DocVersionBannerEnabled({className, versionMetadata}) {
|
|
|
101
101
|
|
|
102
102
|
const {savePreferredVersionName} = useDocsPreferredVersion(pluginId);
|
|
103
103
|
const {latestDocSuggestion, latestVersionSuggestion} =
|
|
104
|
-
useDocVersionSuggestions(pluginId); //
|
|
105
|
-
//
|
|
104
|
+
useDocVersionSuggestions(pluginId); // Try to link to same doc in latest version (not always possible), falling
|
|
105
|
+
// back to main doc of latest version
|
|
106
106
|
|
|
107
107
|
const latestVersionSuggestedDoc =
|
|
108
108
|
latestDocSuggestion ?? getVersionMainDoc(latestVersionSuggestion);
|
|
@@ -27,7 +27,7 @@ function Column({column}) {
|
|
|
27
27
|
return (
|
|
28
28
|
<div className="col footer__col">
|
|
29
29
|
<div className="footer__title">{column.title}</div>
|
|
30
|
-
<ul className="footer__items">
|
|
30
|
+
<ul className="footer__items clean-list">
|
|
31
31
|
{column.items.map((item, i) => (
|
|
32
32
|
<ColumnLinkItem key={i} item={item} />
|
|
33
33
|
))}
|
|
@@ -9,14 +9,13 @@ import clsx from 'clsx';
|
|
|
9
9
|
import {translate} from '@docusaurus/Translate';
|
|
10
10
|
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
11
11
|
import styles from './styles.module.css';
|
|
12
|
-
|
|
13
|
-
function AnchorHeading({as: As, id, ...props}) {
|
|
12
|
+
export default function Heading({as: As, id, ...props}) {
|
|
14
13
|
const {
|
|
15
14
|
navbar: {hideOnScroll},
|
|
16
|
-
} = useThemeConfig();
|
|
15
|
+
} = useThemeConfig(); // H1 headings do not need an id because they don't appear in the TOC.
|
|
17
16
|
|
|
18
|
-
if (!id) {
|
|
19
|
-
return <As {...props} />;
|
|
17
|
+
if (As === 'h1' || !id) {
|
|
18
|
+
return <As {...props} id={undefined} />;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
return (
|
|
@@ -43,18 +42,3 @@ function AnchorHeading({as: As, id, ...props}) {
|
|
|
43
42
|
</As>
|
|
44
43
|
);
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
export default function Heading({as, ...props}) {
|
|
48
|
-
if (as === 'h1') {
|
|
49
|
-
return (
|
|
50
|
-
<h1
|
|
51
|
-
{...props}
|
|
52
|
-
id={undefined} // h1 headings do not need an id because they don't appear in the TOC
|
|
53
|
-
>
|
|
54
|
-
{props.children}
|
|
55
|
-
</h1>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return <AnchorHeading as={as} {...props} />;
|
|
60
|
-
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
import React from 'react';
|
|
8
|
+
export default function IconHome(props) {
|
|
9
|
+
return (
|
|
10
|
+
<svg viewBox="0 0 24 24" {...props}>
|
|
11
|
+
<path
|
|
12
|
+
d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z"
|
|
13
|
+
fill="currentColor"
|
|
14
|
+
/>
|
|
15
|
+
</svg>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -24,7 +24,7 @@ export default function Layout(props) {
|
|
|
24
24
|
children,
|
|
25
25
|
noFooter,
|
|
26
26
|
wrapperClassName,
|
|
27
|
-
//
|
|
27
|
+
// Not really layout-related, but kept for convenience/retro-compatibility
|
|
28
28
|
title,
|
|
29
29
|
description,
|
|
30
30
|
} = props;
|
|
@@ -6,15 +6,13 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
|
-
import styles from './Ul.module.css';
|
|
10
|
-
const containsClassListLocalClass = styles['contains-task-list'];
|
|
11
9
|
|
|
12
10
|
function transformUlClassName(className) {
|
|
13
11
|
return clsx(
|
|
14
12
|
className, // This class is set globally by GitHub/MDX
|
|
15
|
-
// We keep the global class, but
|
|
13
|
+
// We keep the global class, but add Infima class to get list without styling
|
|
16
14
|
// See https://github.com/syntax-tree/mdast-util-to-hast/issues/28
|
|
17
|
-
className?.includes('contains-task-list') &&
|
|
15
|
+
className?.includes('contains-task-list') && 'clean-list',
|
|
18
16
|
);
|
|
19
17
|
}
|
|
20
18
|
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from '@docusaurus/theme-common';
|
|
16
16
|
import NavbarMobileSidebarToggle from '@theme/Navbar/MobileSidebar/Toggle';
|
|
17
17
|
import NavbarLogo from '@theme/Navbar/Logo';
|
|
18
|
+
import NavbarSearch from '@theme/Navbar/Search';
|
|
18
19
|
import styles from './styles.module.css';
|
|
19
20
|
|
|
20
21
|
function useNavbarItems() {
|
|
@@ -62,7 +63,11 @@ export default function NavbarContent() {
|
|
|
62
63
|
<>
|
|
63
64
|
<NavbarItems items={rightItems} />
|
|
64
65
|
<NavbarColorModeToggle className={styles.colorModeToggle} />
|
|
65
|
-
{autoAddSearchBar &&
|
|
66
|
+
{autoAddSearchBar && (
|
|
67
|
+
<NavbarSearch>
|
|
68
|
+
<SearchBar />
|
|
69
|
+
</NavbarSearch>
|
|
70
|
+
)}
|
|
66
71
|
</>
|
|
67
72
|
}
|
|
68
73
|
/>
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
import React from 'react';
|
|
8
|
+
import styles from './styles.module.css';
|
|
9
|
+
export default function NavbarSearch({children}) {
|
|
10
|
+
return <div className={styles.searchBox}>{children}</div>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 (max-width: 996px) {
|
|
9
|
+
.searchBox {
|
|
10
|
+
position: absolute;
|
|
11
|
+
right: var(--ifm-navbar-padding-horizontal);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@media (min-width: 997px) {
|
|
16
|
+
.searchBox {
|
|
17
|
+
padding: var(--ifm-navbar-item-padding-vertical)
|
|
18
|
+
var(--ifm-navbar-item-padding-horizontal);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -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
|
+
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
8
|
+
import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
|
|
9
|
+
import LocaleDropdownNavbarItem from '@theme/NavbarItem/LocaleDropdownNavbarItem';
|
|
10
|
+
import SearchNavbarItem from '@theme/NavbarItem/SearchNavbarItem';
|
|
11
|
+
import HtmlNavbarItem from '@theme/NavbarItem/HtmlNavbarItem';
|
|
12
|
+
import DocNavbarItem from '@theme/NavbarItem/DocNavbarItem';
|
|
13
|
+
import DocSidebarNavbarItem from '@theme/NavbarItem/DocSidebarNavbarItem';
|
|
14
|
+
import DocsVersionNavbarItem from '@theme/NavbarItem/DocsVersionNavbarItem';
|
|
15
|
+
import DocsVersionDropdownNavbarItem from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
|
|
16
|
+
const ComponentTypes = {
|
|
17
|
+
default: DefaultNavbarItem,
|
|
18
|
+
localeDropdown: LocaleDropdownNavbarItem,
|
|
19
|
+
search: SearchNavbarItem,
|
|
20
|
+
dropdown: DropdownNavbarItem,
|
|
21
|
+
html: HtmlNavbarItem,
|
|
22
|
+
doc: DocNavbarItem,
|
|
23
|
+
docSidebar: DocSidebarNavbarItem,
|
|
24
|
+
docsVersion: DocsVersionNavbarItem,
|
|
25
|
+
docsVersionDropdown: DocsVersionDropdownNavbarItem,
|
|
26
|
+
};
|
|
27
|
+
export default ComponentTypes;
|
|
@@ -6,50 +6,33 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
9
|
-
import {
|
|
10
|
-
useLatestVersion,
|
|
11
|
-
useActiveDocContext,
|
|
12
|
-
} from '@docusaurus/plugin-content-docs/client';
|
|
9
|
+
import {useActiveDocContext} from '@docusaurus/plugin-content-docs/client';
|
|
13
10
|
import clsx from 'clsx';
|
|
14
11
|
import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
function getDocInVersions(versions, docId) {
|
|
18
|
-
const allDocs = versions.flatMap((version) => version.docs);
|
|
19
|
-
const doc = allDocs.find((versionDoc) => versionDoc.id === docId);
|
|
20
|
-
|
|
21
|
-
if (!doc) {
|
|
22
|
-
const docIds = allDocs.map((versionDoc) => versionDoc.id).join('\n- ');
|
|
23
|
-
throw new Error(`DocNavbarItem: couldn't find any doc with id "${docId}" in version${
|
|
24
|
-
versions.length ? 's' : ''
|
|
25
|
-
} ${versions.map((version) => version.name).join(', ')}".
|
|
26
|
-
Available doc ids are:\n- ${docIds}`);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return doc;
|
|
30
|
-
}
|
|
31
|
-
|
|
12
|
+
import {useLayoutDoc} from '@docusaurus/theme-common';
|
|
32
13
|
export default function DocNavbarItem({
|
|
33
14
|
docId,
|
|
34
15
|
label: staticLabel,
|
|
35
16
|
docsPluginId,
|
|
36
17
|
...props
|
|
37
18
|
}) {
|
|
38
|
-
const {
|
|
39
|
-
const
|
|
40
|
-
|
|
19
|
+
const {activeDoc} = useActiveDocContext(docsPluginId);
|
|
20
|
+
const doc = useLayoutDoc(docId, docsPluginId); // Draft items are not displayed in the navbar.
|
|
21
|
+
|
|
22
|
+
if (doc === null) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
41
25
|
|
|
42
|
-
const versions = uniq(
|
|
43
|
-
[activeVersion, preferredVersion, latestVersion].filter(Boolean),
|
|
44
|
-
);
|
|
45
|
-
const doc = getDocInVersions(versions, docId);
|
|
46
26
|
const activeDocInfimaClassName = getInfimaActiveClassName(props.mobile);
|
|
47
27
|
return (
|
|
48
28
|
<DefaultNavbarItem
|
|
49
29
|
exact
|
|
50
30
|
{...props}
|
|
51
31
|
className={clsx(props.className, {
|
|
32
|
+
// Do not make the item active if the active doc doesn't have sidebar.
|
|
52
33
|
[activeDocInfimaClassName]:
|
|
34
|
+
// If `activeDoc === doc` react-router will make it active anyways,
|
|
35
|
+
// regardless of the existence of a sidebar
|
|
53
36
|
activeDoc?.sidebar && activeDoc.sidebar === doc.sidebar,
|
|
54
37
|
})}
|
|
55
38
|
activeClassName={activeDocInfimaClassName}
|
|
@@ -6,57 +6,25 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
9
|
-
import {
|
|
10
|
-
useLatestVersion,
|
|
11
|
-
useActiveDocContext,
|
|
12
|
-
} from '@docusaurus/plugin-content-docs/client';
|
|
9
|
+
import {useActiveDocContext} from '@docusaurus/plugin-content-docs/client';
|
|
13
10
|
import clsx from 'clsx';
|
|
14
11
|
import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
function getSidebarLink(versions, sidebarId) {
|
|
18
|
-
const allSidebars = versions
|
|
19
|
-
.flatMap((version) => {
|
|
20
|
-
if (version.sidebars) {
|
|
21
|
-
return Object.entries(version.sidebars);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return undefined;
|
|
25
|
-
})
|
|
26
|
-
.filter((sidebarItem) => !!sidebarItem);
|
|
27
|
-
const sidebarEntry = allSidebars.find((sidebar) => sidebar[0] === sidebarId);
|
|
28
|
-
|
|
29
|
-
if (!sidebarEntry) {
|
|
30
|
-
throw new Error(`DocSidebarNavbarItem: couldn't find any sidebar with id "${sidebarId}" in version${
|
|
31
|
-
versions.length ? 's' : ''
|
|
32
|
-
} ${versions.map((version) => version.name).join(', ')}".
|
|
33
|
-
Available sidebar ids are:
|
|
34
|
-
- ${Object.keys(allSidebars).join('\n- ')}`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!sidebarEntry[1].link) {
|
|
38
|
-
throw new Error(
|
|
39
|
-
`DocSidebarNavbarItem: couldn't find any document for sidebar with id "${sidebarId}"`,
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return sidebarEntry[1].link;
|
|
44
|
-
}
|
|
45
|
-
|
|
12
|
+
import {useLayoutDocsSidebar} from '@docusaurus/theme-common';
|
|
46
13
|
export default function DocSidebarNavbarItem({
|
|
47
14
|
sidebarId,
|
|
48
15
|
label,
|
|
49
16
|
docsPluginId,
|
|
50
17
|
...props
|
|
51
18
|
}) {
|
|
52
|
-
const {
|
|
53
|
-
const
|
|
54
|
-
|
|
19
|
+
const {activeDoc} = useActiveDocContext(docsPluginId);
|
|
20
|
+
const sidebarLink = useLayoutDocsSidebar(sidebarId, docsPluginId).link;
|
|
21
|
+
|
|
22
|
+
if (!sidebarLink) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`DocSidebarNavbarItem: Sidebar with ID "${sidebarId}" doesn't have anything to be linked to.`,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
55
27
|
|
|
56
|
-
const versions = uniq(
|
|
57
|
-
[activeVersion, preferredVersion, latestVersion].filter(Boolean),
|
|
58
|
-
);
|
|
59
|
-
const sidebarLink = getSidebarLink(versions, sidebarId);
|
|
60
28
|
const activeDocInfimaClassName = getInfimaActiveClassName(props.mobile);
|
|
61
29
|
return (
|
|
62
30
|
<DefaultNavbarItem
|