@docusaurus/theme-classic 2.0.0-beta.8bda3b2db → 2.0.0-beta.9
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/README.md +1 -1
- package/codeTranslations/ar.json +12 -7
- package/codeTranslations/base.json +17 -7
- package/codeTranslations/bn.json +11 -5
- package/codeTranslations/cs.json +62 -0
- package/codeTranslations/da.json +8 -3
- package/codeTranslations/de.json +8 -3
- package/codeTranslations/es.json +15 -10
- package/codeTranslations/fa.json +31 -26
- package/codeTranslations/fil.json +8 -3
- package/codeTranslations/fr.json +8 -3
- package/codeTranslations/he.json +9 -4
- package/codeTranslations/hi.json +9 -4
- package/codeTranslations/ja.json +8 -3
- package/codeTranslations/ko.json +8 -3
- package/codeTranslations/pl.json +8 -3
- package/codeTranslations/pt-BR.json +16 -11
- package/codeTranslations/pt-PT.json +8 -3
- package/codeTranslations/ru.json +10 -5
- package/codeTranslations/sr.json +62 -0
- package/codeTranslations/tr.json +9 -4
- package/codeTranslations/vi.json +10 -5
- package/codeTranslations/zh-Hans.json +9 -4
- package/codeTranslations/zh-Hant.json +9 -4
- package/lib/__tests__/validateThemeConfig.test.js +277 -3
- package/lib/admonitions.css +35 -0
- package/lib/index.js +31 -8
- package/lib/prism-include-languages.js +9 -5
- package/lib/theme/AnnouncementBar/index.js +10 -16
- package/lib/theme/AnnouncementBar/styles.module.css +25 -30
- package/lib/theme/BackToTopButton/index.js +140 -0
- package/lib/theme/BackToTopButton/styles.module.css +42 -0
- package/lib/theme/BlogArchivePage/index.js +89 -0
- package/lib/theme/BlogLayout/index.js +51 -0
- package/lib/theme/BlogListPage/index.js +10 -21
- package/lib/theme/BlogPostAuthor/index.js +51 -0
- package/lib/theme/BlogPostAuthor/styles.module.css +12 -0
- package/lib/theme/BlogPostAuthors/index.js +47 -0
- package/lib/theme/BlogPostAuthors/styles.module.css +11 -0
- package/lib/theme/BlogPostItem/index.js +58 -67
- package/lib/theme/BlogPostPage/index.js +37 -24
- package/lib/theme/BlogSidebar/styles.module.css +2 -2
- package/lib/theme/BlogTagsListPage/index.js +8 -44
- package/lib/theme/BlogTagsPostsPage/index.js +24 -38
- package/lib/theme/CodeBlock/index.js +45 -41
- package/lib/theme/CodeBlock/styles.module.css +6 -9
- package/lib/theme/Details/index.js +30 -0
- package/lib/theme/Details/styles.module.css +13 -0
- package/lib/theme/DocItem/index.js +29 -45
- package/lib/theme/DocItem/styles.module.css +5 -9
- package/lib/theme/DocItemFooter/index.js +79 -0
- package/lib/theme/DocItemFooter/styles.module.css +18 -0
- package/lib/theme/DocPage/index.js +25 -49
- package/lib/theme/DocPage/styles.module.css +8 -23
- package/lib/theme/DocSidebar/index.js +45 -227
- package/lib/theme/DocSidebar/styles.module.css +0 -18
- package/lib/theme/DocSidebarItem/index.js +177 -0
- package/lib/theme/DocSidebarItem/styles.module.css +15 -0
- package/lib/theme/DocTagDocListPage/index.js +89 -0
- package/lib/theme/DocTagsListPage/index.js +44 -0
- package/lib/theme/{DocVersionSuggestions → DocVersionBanner}/index.js +37 -18
- package/lib/theme/EditThisPage/index.js +3 -1
- package/lib/theme/Footer/index.js +13 -4
- package/lib/theme/Heading/index.js +7 -9
- package/lib/theme/Heading/styles.css +4 -6
- package/lib/theme/Heading/styles.module.css +9 -5
- package/lib/theme/IconClose/index.js +31 -0
- package/lib/theme/LastUpdated/index.js +4 -2
- package/lib/theme/LayoutHead/index.js +13 -11
- package/lib/theme/LayoutProviders/index.js +11 -5
- package/lib/theme/Logo/index.js +14 -12
- package/lib/theme/MDXComponents/index.js +45 -4
- package/lib/theme/MDXComponents/styles.css +11 -0
- package/lib/theme/MDXPage/index.js +2 -1
- package/lib/theme/Navbar/index.js +164 -42
- package/lib/theme/Navbar/styles.module.css +10 -3
- package/lib/theme/NavbarItem/DefaultNavbarItem.js +27 -123
- package/lib/theme/NavbarItem/DocNavbarItem.js +6 -5
- package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +19 -12
- package/lib/theme/NavbarItem/DropdownNavbarItem.js +155 -0
- package/lib/theme/NavbarItem/{LocaleDropdownNavbarItem.js → LocaleDropdownNavbarItem/index.js} +5 -6
- package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css +11 -0
- package/lib/theme/NavbarItem/index.js +31 -11
- package/lib/theme/Seo/index.js +10 -7
- package/lib/theme/SkipToContent/index.js +9 -3
- package/lib/theme/SkipToContent/styles.module.css +1 -0
- package/lib/theme/TOC/index.js +9 -29
- package/lib/theme/TOC/styles.module.css +1 -1
- package/lib/theme/TOCCollapsible/index.js +53 -0
- package/lib/theme/TOCCollapsible/styles.module.css +50 -0
- package/lib/theme/TOCInline/index.js +7 -27
- package/lib/theme/TOCItems/index.js +78 -0
- package/lib/theme/Tabs/__tests__/index.test.js +123 -0
- package/lib/theme/Tabs/index.js +73 -50
- package/lib/theme/Tabs/styles.module.css +0 -13
- package/lib/theme/Tag/index.js +40 -0
- package/lib/theme/Tag/styles.module.css +70 -0
- package/lib/theme/TagsListByLetter/index.js +48 -0
- package/lib/theme/TagsListByLetter/styles.module.css +11 -0
- package/lib/theme/TagsListInline/index.js +44 -0
- package/lib/theme/TagsListInline/styles.module.css +15 -0
- package/lib/theme/ThemedImage/index.js +4 -5
- package/lib/theme/Toggle/index.js +23 -18
- package/lib/theme/Toggle/styles.module.css +91 -0
- package/lib/theme/UserPreferencesProvider/index.js +1 -9
- package/lib/theme/hooks/useHideableNavbar.js +14 -32
- package/lib/theme/hooks/useTabGroupChoice.js +2 -4
- package/lib/theme/hooks/useTheme.js +2 -2
- package/lib/theme/hooks/useWindowSize.js +33 -20
- package/lib/theme/prism-include-languages.js +4 -3
- package/lib/translations.js +4 -4
- package/lib/types.d.ts +338 -138
- package/lib/validateThemeConfig.js +226 -245
- package/lib-next/__tests__/validateThemeConfig.test.js +277 -3
- package/lib-next/admonitions.css +35 -0
- package/lib-next/index.js +33 -7
- package/lib-next/prism-include-languages.js +0 -2
- package/lib-next/theme/AnnouncementBar/index.js +9 -18
- package/lib-next/theme/AnnouncementBar/styles.module.css +25 -30
- package/lib-next/theme/BackToTopButton/index.js +131 -0
- package/lib-next/theme/BackToTopButton/styles.module.css +42 -0
- package/lib-next/theme/BlogArchivePage/index.js +80 -0
- package/lib-next/theme/BlogLayout/index.js +40 -0
- package/lib-next/theme/BlogListPage/index.js +16 -24
- package/lib-next/theme/BlogPostAuthor/index.js +46 -0
- package/lib-next/theme/BlogPostAuthor/styles.module.css +12 -0
- package/lib-next/theme/BlogPostAuthors/index.js +34 -0
- package/lib-next/theme/BlogPostAuthors/styles.module.css +11 -0
- package/lib-next/theme/BlogPostItem/index.js +79 -86
- package/lib-next/theme/BlogPostPage/index.js +70 -35
- package/lib-next/theme/BlogSidebar/styles.module.css +2 -2
- package/lib-next/theme/BlogTagsListPage/index.js +13 -54
- package/lib-next/theme/BlogTagsPostsPage/index.js +28 -38
- package/lib-next/theme/CodeBlock/index.js +54 -53
- package/lib-next/theme/CodeBlock/styles.module.css +6 -9
- package/lib-next/theme/Details/index.js +20 -0
- package/lib-next/theme/Details/styles.module.css +13 -0
- package/lib-next/theme/DocItem/index.js +46 -55
- package/lib-next/theme/DocItem/styles.module.css +5 -9
- package/lib-next/theme/DocItemFooter/index.js +79 -0
- package/lib-next/theme/DocItemFooter/styles.module.css +18 -0
- package/lib-next/theme/DocPage/index.js +25 -43
- package/lib-next/theme/DocPage/styles.module.css +8 -23
- package/lib-next/theme/DocSidebar/index.js +59 -288
- package/lib-next/theme/DocSidebar/styles.module.css +0 -18
- package/lib-next/theme/DocSidebarItem/index.js +181 -0
- package/lib-next/theme/DocSidebarItem/styles.module.css +15 -0
- package/lib-next/theme/DocTagDocListPage/index.js +89 -0
- package/lib-next/theme/DocTagsListPage/index.js +38 -0
- package/lib-next/theme/{DocVersionSuggestions → DocVersionBanner}/index.js +44 -36
- package/lib-next/theme/EditThisPage/index.js +6 -1
- package/lib-next/theme/Footer/index.js +24 -4
- package/lib-next/theme/Heading/index.js +10 -13
- package/lib-next/theme/Heading/styles.css +4 -6
- package/lib-next/theme/Heading/styles.module.css +9 -5
- package/lib-next/theme/IconClose/index.js +23 -0
- package/lib-next/theme/LastUpdated/index.js +3 -2
- package/lib-next/theme/LayoutHead/index.js +9 -15
- package/lib-next/theme/LayoutProviders/index.js +17 -6
- package/lib-next/theme/Logo/index.js +23 -19
- package/lib-next/theme/MDXComponents/index.js +34 -7
- package/lib-next/theme/MDXComponents/styles.css +11 -0
- package/lib-next/theme/MDXPage/index.js +10 -2
- package/lib-next/theme/Navbar/index.js +192 -56
- package/lib-next/theme/Navbar/styles.module.css +10 -3
- package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +45 -147
- package/lib-next/theme/NavbarItem/DocNavbarItem.js +6 -5
- package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +31 -19
- package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +158 -0
- package/lib-next/theme/NavbarItem/{LocaleDropdownNavbarItem.js → LocaleDropdownNavbarItem/index.js} +4 -8
- package/lib-next/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css +11 -0
- package/lib-next/theme/NavbarItem/index.js +25 -12
- package/lib-next/theme/Seo/index.js +11 -7
- package/lib-next/theme/SkipToContent/index.js +5 -6
- package/lib-next/theme/SkipToContent/styles.module.css +1 -0
- package/lib-next/theme/TOC/index.js +12 -36
- package/lib-next/theme/TOC/styles.module.css +1 -1
- package/lib-next/theme/TOCCollapsible/index.js +54 -0
- package/lib-next/theme/TOCCollapsible/styles.module.css +50 -0
- package/lib-next/theme/TOCInline/index.js +10 -28
- package/lib-next/theme/TOCItems/index.js +85 -0
- package/lib-next/theme/Tabs/__tests__/index.test.js +142 -0
- package/lib-next/theme/Tabs/index.js +91 -43
- package/lib-next/theme/Tabs/styles.module.css +0 -13
- package/lib-next/theme/Tag/index.js +27 -0
- package/lib-next/theme/Tag/styles.module.css +70 -0
- package/lib-next/theme/TagsListByLetter/index.js +42 -0
- package/lib-next/theme/TagsListByLetter/styles.module.css +11 -0
- package/lib-next/theme/TagsListInline/index.js +31 -0
- package/lib-next/theme/TagsListInline/styles.module.css +15 -0
- package/lib-next/theme/ThemedImage/index.js +5 -6
- package/lib-next/theme/Toggle/index.js +20 -15
- package/lib-next/theme/Toggle/styles.module.css +91 -0
- package/lib-next/theme/UserPreferencesProvider/index.js +0 -4
- package/lib-next/theme/hooks/useHideableNavbar.js +31 -44
- package/lib-next/theme/hooks/useTabGroupChoice.js +2 -4
- package/lib-next/theme/hooks/useTheme.js +2 -2
- package/lib-next/theme/hooks/useWindowSize.js +34 -20
- package/lib-next/theme/prism-include-languages.js +2 -1
- package/lib-next/translations.js +6 -10
- package/lib-next/types.d.ts +338 -138
- package/lib-next/validateThemeConfig.js +134 -110
- package/package.json +24 -19
- package/src/__tests__/validateThemeConfig.test.js +277 -3
- package/src/admonitions.css +35 -0
- package/src/index.ts +44 -14
- package/src/{prism-include-languages.js → prism-include-languages.ts} +0 -0
- package/src/theme/AnnouncementBar/index.tsx +10 -17
- package/src/theme/AnnouncementBar/styles.module.css +25 -30
- package/src/theme/BackToTopButton/index.tsx +142 -0
- package/src/theme/BackToTopButton/styles.module.css +42 -0
- package/src/theme/BlogArchivePage/index.tsx +91 -0
- package/src/theme/BlogLayout/index.tsx +44 -0
- package/src/theme/BlogListPage/index.tsx +17 -24
- package/src/theme/BlogPostAuthor/index.tsx +49 -0
- package/src/theme/BlogPostAuthor/styles.module.css +12 -0
- package/src/theme/BlogPostAuthors/index.tsx +36 -0
- package/src/theme/BlogPostAuthors/styles.module.css +11 -0
- package/src/theme/BlogPostItem/index.tsx +70 -80
- package/src/theme/BlogPostPage/index.tsx +72 -35
- package/src/theme/BlogSidebar/styles.module.css +2 -2
- package/src/theme/BlogTagsListPage/index.tsx +13 -56
- package/src/theme/BlogTagsPostsPage/index.tsx +28 -38
- package/src/theme/CodeBlock/index.tsx +70 -55
- package/src/theme/CodeBlock/styles.module.css +6 -9
- package/src/theme/Details/index.tsx +24 -0
- package/src/theme/Details/styles.module.css +13 -0
- package/src/theme/DocItem/index.tsx +49 -55
- package/src/theme/DocItem/styles.module.css +5 -9
- package/src/theme/DocItemFooter/index.tsx +91 -0
- package/src/theme/DocItemFooter/styles.module.css +18 -0
- package/src/theme/DocPage/index.tsx +24 -38
- package/src/theme/DocPage/styles.module.css +8 -23
- package/src/theme/DocSidebar/index.tsx +70 -300
- package/src/theme/DocSidebar/styles.module.css +0 -18
- package/src/theme/DocSidebarItem/index.tsx +206 -0
- package/src/theme/DocSidebarItem/styles.module.css +15 -0
- package/src/theme/DocTagDocListPage/index.tsx +89 -0
- package/src/theme/DocTagsListPage/index.tsx +41 -0
- package/src/theme/{DocVersionSuggestions → DocVersionBanner}/index.tsx +58 -44
- package/src/theme/EditThisPage/index.tsx +6 -1
- package/src/theme/Footer/index.tsx +26 -4
- package/src/theme/Heading/index.tsx +10 -13
- package/src/theme/Heading/styles.css +4 -6
- package/src/theme/Heading/styles.module.css +9 -5
- package/src/theme/IconClose/index.tsx +26 -0
- package/src/theme/LastUpdated/index.tsx +3 -2
- package/src/theme/LayoutHead/index.tsx +9 -9
- package/src/theme/LayoutProviders/index.tsx +17 -6
- package/src/theme/Logo/index.tsx +19 -15
- package/src/theme/MDXComponents/index.tsx +39 -5
- package/src/theme/MDXComponents/styles.css +11 -0
- package/src/theme/MDXPage/index.tsx +10 -2
- package/src/theme/Navbar/index.tsx +202 -61
- package/src/theme/Navbar/styles.module.css +10 -3
- package/src/theme/NavbarItem/DefaultNavbarItem.tsx +42 -154
- package/src/theme/NavbarItem/DocNavbarItem.tsx +11 -14
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +33 -21
- package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +7 -3
- package/src/theme/NavbarItem/DropdownNavbarItem.tsx +180 -0
- package/src/theme/NavbarItem/{LocaleDropdownNavbarItem.tsx → LocaleDropdownNavbarItem/index.tsx} +8 -7
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css +11 -0
- package/src/theme/NavbarItem/index.tsx +41 -16
- package/src/theme/Seo/index.tsx +7 -4
- package/src/theme/SkipToContent/index.tsx +5 -6
- package/src/theme/SkipToContent/styles.module.css +1 -0
- package/src/theme/TOC/index.tsx +12 -41
- package/src/theme/TOC/styles.module.css +1 -1
- package/src/theme/TOCCollapsible/index.tsx +58 -0
- package/src/theme/TOCCollapsible/styles.module.css +50 -0
- package/src/theme/TOCInline/index.tsx +13 -32
- package/src/theme/TOCItems/index.tsx +96 -0
- package/src/theme/Tabs/__tests__/index.test.tsx +129 -0
- package/src/theme/Tabs/index.tsx +93 -49
- package/src/theme/Tabs/styles.module.css +0 -13
- package/src/theme/Tag/index.tsx +31 -0
- package/src/theme/Tag/styles.module.css +70 -0
- package/src/theme/TagsListByLetter/index.tsx +45 -0
- package/src/theme/TagsListByLetter/styles.module.css +11 -0
- package/src/theme/TagsListInline/index.tsx +35 -0
- package/src/theme/TagsListInline/styles.module.css +15 -0
- package/src/theme/ThemedImage/index.tsx +6 -6
- package/src/theme/Toggle/index.tsx +20 -15
- package/src/theme/Toggle/styles.module.css +91 -0
- package/src/theme/UserPreferencesProvider/index.tsx +0 -5
- package/src/theme/hooks/useContextualSearchFilters.ts +1 -1
- package/src/theme/hooks/useHideableNavbar.ts +32 -45
- package/src/theme/hooks/useTabGroupChoice.ts +4 -4
- package/src/theme/hooks/useTheme.ts +2 -2
- package/src/theme/hooks/useWindowSize.ts +38 -20
- package/src/theme/prism-include-languages.ts +3 -2
- package/src/translations.ts +6 -10
- package/src/types.d.ts +338 -138
- package/src/{validateThemeConfig.js → validateThemeConfig.ts} +144 -90
- package/tsconfig.json +1 -2
- package/update-code-translations.js +10 -6
- package/update-code-translations.test.js +1 -1
- package/update.js +151 -0
- package/lib/theme/Toggle/styles.css +0 -103
- package/lib/theme/hooks/useAnnouncementBar.js +0 -63
- package/lib/theme/hooks/useScrollPosition.js +0 -49
- package/lib/theme/hooks/useTOCHighlight.js +0 -87
- package/lib-next/theme/Toggle/styles.css +0 -103
- package/lib-next/theme/hooks/useAnnouncementBar.js +0 -49
- package/lib-next/theme/hooks/useScrollPosition.js +0 -38
- package/lib-next/theme/hooks/useTOCHighlight.js +0 -84
- package/src/theme/Toggle/styles.css +0 -103
- package/src/theme/hooks/useAnnouncementBar.ts +0 -58
- package/src/theme/hooks/useScrollPosition.ts +0 -45
- package/src/theme/hooks/useTOCHighlight.ts +0 -98
|
@@ -4,227 +4,34 @@
|
|
|
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, {useState
|
|
7
|
+
import React, {useState} from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import {
|
|
10
10
|
useThemeConfig,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
useAnnouncementBar,
|
|
12
|
+
MobileSecondaryMenuFiller,
|
|
13
|
+
ThemeClassNames,
|
|
14
|
+
useScrollPosition,
|
|
13
15
|
} from '@docusaurus/theme-common';
|
|
14
|
-
import
|
|
15
|
-
import useLockBodyScroll from '@theme/hooks/useLockBodyScroll';
|
|
16
|
-
import useWindowSize, {windowSizes} from '@theme/hooks/useWindowSize';
|
|
17
|
-
import useScrollPosition from '@theme/hooks/useScrollPosition';
|
|
18
|
-
import Link from '@docusaurus/Link';
|
|
19
|
-
import isInternalUrl from '@docusaurus/isInternalUrl';
|
|
16
|
+
import useWindowSize from '@theme/hooks/useWindowSize';
|
|
20
17
|
import Logo from '@theme/Logo';
|
|
21
18
|
import IconArrow from '@theme/IconArrow';
|
|
22
|
-
import IconMenu from '@theme/IconMenu';
|
|
23
|
-
import IconExternalLink from '@theme/IconExternalLink';
|
|
24
19
|
import {translate} from '@docusaurus/Translate';
|
|
20
|
+
import {DocSidebarItems} from '@theme/DocSidebarItem';
|
|
25
21
|
import styles from './styles.module.css';
|
|
26
|
-
const MOBILE_TOGGLE_SIZE = 24;
|
|
27
|
-
|
|
28
|
-
const isActiveSidebarItem = (item, activePath) => {
|
|
29
|
-
if (item.type === 'link') {
|
|
30
|
-
return isSamePath(item.href, activePath);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (item.type === 'category') {
|
|
34
|
-
return item.items.some((subItem) =>
|
|
35
|
-
isActiveSidebarItem(subItem, activePath),
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return false;
|
|
40
|
-
}; // Optimize sidebar at each "level"
|
|
41
|
-
// TODO this item should probably not receive the "activePath" props
|
|
42
|
-
// TODO this triggers whole sidebar re-renders on navigation
|
|
43
|
-
|
|
44
|
-
const DocSidebarItems = memo(function DocSidebarItems({items, ...props}) {
|
|
45
|
-
return items.map((item, index) => (
|
|
46
|
-
<DocSidebarItem
|
|
47
|
-
key={index} // sidebar is static, the index does not change
|
|
48
|
-
item={item}
|
|
49
|
-
{...props}
|
|
50
|
-
/>
|
|
51
|
-
));
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
function DocSidebarItem(props) {
|
|
55
|
-
switch (props.item.type) {
|
|
56
|
-
case 'category':
|
|
57
|
-
return <DocSidebarItemCategory {...props} />;
|
|
58
|
-
|
|
59
|
-
case 'link':
|
|
60
|
-
default:
|
|
61
|
-
return <DocSidebarItemLink {...props} />;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function DocSidebarItemCategory({
|
|
66
|
-
item,
|
|
67
|
-
onItemClick,
|
|
68
|
-
collapsible,
|
|
69
|
-
activePath,
|
|
70
|
-
...props
|
|
71
|
-
}) {
|
|
72
|
-
const {items, label} = item;
|
|
73
|
-
const isActive = isActiveSidebarItem(item, activePath);
|
|
74
|
-
const wasActive = usePrevious(isActive); // active categories are always initialized as expanded
|
|
75
|
-
// the default (item.collapsed) is only used for non-active categories
|
|
76
|
-
|
|
77
|
-
const [collapsed, setCollapsed] = useState(() => {
|
|
78
|
-
if (!collapsible) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return isActive ? false : item.collapsed;
|
|
83
|
-
});
|
|
84
|
-
const menuListRef = useRef(null);
|
|
85
|
-
const [menuListHeight, setMenuListHeight] = useState(undefined);
|
|
86
|
-
|
|
87
|
-
const handleMenuListHeight = (calc = true) => {
|
|
88
|
-
setMenuListHeight(
|
|
89
|
-
calc ? `${menuListRef.current?.scrollHeight}px` : undefined,
|
|
90
|
-
);
|
|
91
|
-
}; // If we navigate to a category, it should automatically expand itself
|
|
92
|
-
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
const justBecameActive = isActive && !wasActive;
|
|
95
|
-
|
|
96
|
-
if (justBecameActive && collapsed) {
|
|
97
|
-
setCollapsed(false);
|
|
98
|
-
}
|
|
99
|
-
}, [isActive, wasActive, collapsed]);
|
|
100
|
-
const handleItemClick = useCallback(
|
|
101
|
-
(e) => {
|
|
102
|
-
e.preventDefault();
|
|
103
|
-
|
|
104
|
-
if (!menuListHeight) {
|
|
105
|
-
handleMenuListHeight();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
setTimeout(() => setCollapsed((state) => !state), 100);
|
|
109
|
-
},
|
|
110
|
-
[menuListHeight],
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
if (items.length === 0) {
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return (
|
|
118
|
-
<li
|
|
119
|
-
className={clsx('menu__list-item', {
|
|
120
|
-
'menu__list-item--collapsed': collapsed,
|
|
121
|
-
})}>
|
|
122
|
-
<a
|
|
123
|
-
className={clsx('menu__link', {
|
|
124
|
-
'menu__link--sublist': collapsible,
|
|
125
|
-
'menu__link--active': collapsible && isActive,
|
|
126
|
-
[styles.menuLinkText]: !collapsible,
|
|
127
|
-
})}
|
|
128
|
-
onClick={collapsible ? handleItemClick : undefined}
|
|
129
|
-
href={collapsible ? '#!' : undefined}
|
|
130
|
-
{...props}>
|
|
131
|
-
{label}
|
|
132
|
-
</a>
|
|
133
|
-
<ul
|
|
134
|
-
className="menu__list"
|
|
135
|
-
ref={menuListRef}
|
|
136
|
-
style={{
|
|
137
|
-
height: menuListHeight,
|
|
138
|
-
}}
|
|
139
|
-
onTransitionEnd={() => {
|
|
140
|
-
if (!collapsed) {
|
|
141
|
-
handleMenuListHeight(false);
|
|
142
|
-
}
|
|
143
|
-
}}>
|
|
144
|
-
<DocSidebarItems
|
|
145
|
-
items={items}
|
|
146
|
-
tabIndex={collapsed ? '-1' : '0'}
|
|
147
|
-
onItemClick={onItemClick}
|
|
148
|
-
collapsible={collapsible}
|
|
149
|
-
activePath={activePath}
|
|
150
|
-
/>
|
|
151
|
-
</ul>
|
|
152
|
-
</li>
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function DocSidebarItemLink({
|
|
157
|
-
item,
|
|
158
|
-
onItemClick,
|
|
159
|
-
activePath,
|
|
160
|
-
collapsible: _collapsible,
|
|
161
|
-
...props
|
|
162
|
-
}) {
|
|
163
|
-
const {href, label} = item;
|
|
164
|
-
const isActive = isActiveSidebarItem(item, activePath);
|
|
165
|
-
return (
|
|
166
|
-
<li className="menu__list-item" key={label}>
|
|
167
|
-
<Link
|
|
168
|
-
className={clsx('menu__link', {
|
|
169
|
-
'menu__link--active': isActive,
|
|
170
|
-
})}
|
|
171
|
-
to={href}
|
|
172
|
-
{...(isInternalUrl(href) && {
|
|
173
|
-
isNavLink: true,
|
|
174
|
-
exact: true,
|
|
175
|
-
onClick: onItemClick,
|
|
176
|
-
})}
|
|
177
|
-
{...props}>
|
|
178
|
-
{isInternalUrl(href) ? (
|
|
179
|
-
label
|
|
180
|
-
) : (
|
|
181
|
-
<span>
|
|
182
|
-
{label}
|
|
183
|
-
<IconExternalLink />
|
|
184
|
-
</span>
|
|
185
|
-
)}
|
|
186
|
-
</Link>
|
|
187
|
-
</li>
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
22
|
|
|
191
23
|
function useShowAnnouncementBar() {
|
|
192
|
-
const {
|
|
193
|
-
const [showAnnouncementBar, setShowAnnouncementBar] = useState(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
return showAnnouncementBar;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function useResponsiveSidebar() {
|
|
205
|
-
const [showResponsiveSidebar, setShowResponsiveSidebar] = useState(false);
|
|
206
|
-
useLockBodyScroll(showResponsiveSidebar);
|
|
207
|
-
const windowSize = useWindowSize();
|
|
208
|
-
useEffect(() => {
|
|
209
|
-
if (windowSize === windowSizes.desktop) {
|
|
210
|
-
setShowResponsiveSidebar(false);
|
|
211
|
-
}
|
|
212
|
-
}, [windowSize]);
|
|
213
|
-
const closeResponsiveSidebar = useCallback(
|
|
214
|
-
(e) => {
|
|
215
|
-
e.target.blur();
|
|
216
|
-
setShowResponsiveSidebar(false);
|
|
24
|
+
const {isActive} = useAnnouncementBar();
|
|
25
|
+
const [showAnnouncementBar, setShowAnnouncementBar] = useState(isActive);
|
|
26
|
+
useScrollPosition(
|
|
27
|
+
({scrollY}) => {
|
|
28
|
+
if (isActive) {
|
|
29
|
+
setShowAnnouncementBar(scrollY === 0);
|
|
30
|
+
}
|
|
217
31
|
},
|
|
218
|
-
[
|
|
32
|
+
[isActive],
|
|
219
33
|
);
|
|
220
|
-
|
|
221
|
-
setShowResponsiveSidebar((value) => !value);
|
|
222
|
-
}, [setShowResponsiveSidebar]);
|
|
223
|
-
return {
|
|
224
|
-
showResponsiveSidebar,
|
|
225
|
-
closeResponsiveSidebar,
|
|
226
|
-
toggleResponsiveSidebar,
|
|
227
|
-
};
|
|
34
|
+
return isActive && showAnnouncementBar;
|
|
228
35
|
}
|
|
229
36
|
|
|
230
37
|
function HideableSidebarButton({onClick}) {
|
|
@@ -251,62 +58,12 @@ function HideableSidebarButton({onClick}) {
|
|
|
251
58
|
);
|
|
252
59
|
}
|
|
253
60
|
|
|
254
|
-
function
|
|
255
|
-
return (
|
|
256
|
-
<button
|
|
257
|
-
aria-label={
|
|
258
|
-
responsiveSidebarOpened
|
|
259
|
-
? translate({
|
|
260
|
-
id: 'theme.docs.sidebar.responsiveCloseButtonLabel',
|
|
261
|
-
message: 'Close menu',
|
|
262
|
-
description:
|
|
263
|
-
'The ARIA label for close button of mobile doc sidebar',
|
|
264
|
-
})
|
|
265
|
-
: translate({
|
|
266
|
-
id: 'theme.docs.sidebar.responsiveOpenButtonLabel',
|
|
267
|
-
message: 'Open menu',
|
|
268
|
-
description:
|
|
269
|
-
'The ARIA label for open button of mobile doc sidebar',
|
|
270
|
-
})
|
|
271
|
-
}
|
|
272
|
-
aria-haspopup="true"
|
|
273
|
-
className="button button--secondary button--sm menu__button"
|
|
274
|
-
type="button"
|
|
275
|
-
onClick={onClick}>
|
|
276
|
-
{responsiveSidebarOpened ? (
|
|
277
|
-
<span
|
|
278
|
-
className={clsx(styles.sidebarMenuIcon, styles.sidebarMenuCloseIcon)}>
|
|
279
|
-
×
|
|
280
|
-
</span>
|
|
281
|
-
) : (
|
|
282
|
-
<IconMenu
|
|
283
|
-
className={styles.sidebarMenuIcon}
|
|
284
|
-
height={MOBILE_TOGGLE_SIZE}
|
|
285
|
-
width={MOBILE_TOGGLE_SIZE}
|
|
286
|
-
/>
|
|
287
|
-
)}
|
|
288
|
-
</button>
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function DocSidebar({
|
|
293
|
-
path,
|
|
294
|
-
sidebar,
|
|
295
|
-
sidebarCollapsible = true,
|
|
296
|
-
onCollapse,
|
|
297
|
-
isHidden,
|
|
298
|
-
}) {
|
|
61
|
+
function DocSidebarDesktop({path, sidebar, onCollapse, isHidden}) {
|
|
299
62
|
const showAnnouncementBar = useShowAnnouncementBar();
|
|
300
63
|
const {
|
|
301
64
|
navbar: {hideOnScroll},
|
|
302
65
|
hideableSidebar,
|
|
303
66
|
} = useThemeConfig();
|
|
304
|
-
const {isAnnouncementBarClosed} = useUserPreferencesContext();
|
|
305
|
-
const {
|
|
306
|
-
showResponsiveSidebar,
|
|
307
|
-
closeResponsiveSidebar,
|
|
308
|
-
toggleResponsiveSidebar,
|
|
309
|
-
} = useResponsiveSidebar();
|
|
310
67
|
return (
|
|
311
68
|
<div
|
|
312
69
|
className={clsx(styles.sidebar, {
|
|
@@ -315,34 +72,11 @@ function DocSidebar({
|
|
|
315
72
|
})}>
|
|
316
73
|
{hideOnScroll && <Logo tabIndex={-1} className={styles.sidebarLogo} />}
|
|
317
74
|
<nav
|
|
318
|
-
className={clsx(
|
|
319
|
-
|
|
320
|
-
'menu--responsive',
|
|
321
|
-
'thin-scrollbar',
|
|
322
|
-
styles.menu,
|
|
323
|
-
{
|
|
324
|
-
'menu--show': showResponsiveSidebar,
|
|
325
|
-
[styles.menuWithAnnouncementBar]:
|
|
326
|
-
!isAnnouncementBarClosed && showAnnouncementBar,
|
|
327
|
-
},
|
|
328
|
-
)}
|
|
329
|
-
aria-label={translate({
|
|
330
|
-
id: 'theme.docs.sidebar.navAriaLabel',
|
|
331
|
-
message: 'Sidebar navigation',
|
|
332
|
-
description: 'The ARIA label for documentation menu',
|
|
75
|
+
className={clsx('menu thin-scrollbar', styles.menu, {
|
|
76
|
+
[styles.menuWithAnnouncementBar]: showAnnouncementBar,
|
|
333
77
|
})}>
|
|
334
|
-
<
|
|
335
|
-
|
|
336
|
-
onClick={toggleResponsiveSidebar}
|
|
337
|
-
/>
|
|
338
|
-
|
|
339
|
-
<ul className="menu__list">
|
|
340
|
-
<DocSidebarItems
|
|
341
|
-
items={sidebar}
|
|
342
|
-
onItemClick={closeResponsiveSidebar}
|
|
343
|
-
collapsible={sidebarCollapsible}
|
|
344
|
-
activePath={path}
|
|
345
|
-
/>
|
|
78
|
+
<ul className={clsx(ThemeClassNames.docs.docSidebarMenu, 'menu__list')}>
|
|
79
|
+
<DocSidebarItems items={sidebar} activePath={path} level={1} />
|
|
346
80
|
</ul>
|
|
347
81
|
</nav>
|
|
348
82
|
{hideableSidebar && <HideableSidebarButton onClick={onCollapse} />}
|
|
@@ -350,4 +84,41 @@ function DocSidebar({
|
|
|
350
84
|
);
|
|
351
85
|
}
|
|
352
86
|
|
|
353
|
-
|
|
87
|
+
const DocSidebarMobileSecondaryMenu = ({toggleSidebar, sidebar, path}) => {
|
|
88
|
+
return (
|
|
89
|
+
<ul className={clsx(ThemeClassNames.docs.docSidebarMenu, 'menu__list')}>
|
|
90
|
+
<DocSidebarItems
|
|
91
|
+
items={sidebar}
|
|
92
|
+
activePath={path}
|
|
93
|
+
onItemClick={() => toggleSidebar()}
|
|
94
|
+
level={1}
|
|
95
|
+
/>
|
|
96
|
+
</ul>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
function DocSidebarMobile(props) {
|
|
101
|
+
return (
|
|
102
|
+
<MobileSecondaryMenuFiller
|
|
103
|
+
component={DocSidebarMobileSecondaryMenu}
|
|
104
|
+
props={props}
|
|
105
|
+
/>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const DocSidebarDesktopMemo = React.memo(DocSidebarDesktop);
|
|
110
|
+
const DocSidebarMobileMemo = React.memo(DocSidebarMobile);
|
|
111
|
+
export default function DocSidebar(props) {
|
|
112
|
+
const windowSize = useWindowSize(); // Desktop sidebar visible on hydration: need SSR rendering
|
|
113
|
+
|
|
114
|
+
const shouldRenderSidebarDesktop =
|
|
115
|
+
windowSize === 'desktop' || windowSize === 'ssr'; // Mobile sidebar not visible on hydration: can avoid SSR rendering
|
|
116
|
+
|
|
117
|
+
const shouldRenderSidebarMobile = windowSize === 'mobile';
|
|
118
|
+
return (
|
|
119
|
+
<>
|
|
120
|
+
{shouldRenderSidebarDesktop && <DocSidebarDesktopMemo {...props} />}
|
|
121
|
+
{shouldRenderSidebarMobile && <DocSidebarMobileMemo {...props} />}
|
|
122
|
+
</>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
@@ -53,14 +53,6 @@
|
|
|
53
53
|
padding: 0.5rem;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
.menuLinkText {
|
|
57
|
-
cursor: initial;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.menuLinkText:hover {
|
|
61
|
-
background: none;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
56
|
.menuWithAnnouncementBar {
|
|
65
57
|
margin-bottom: var(--docusaurus-announcement-bar-height);
|
|
66
58
|
}
|
|
@@ -112,13 +104,3 @@
|
|
|
112
104
|
line-height: 0.9;
|
|
113
105
|
width: 24px;
|
|
114
106
|
}
|
|
115
|
-
|
|
116
|
-
:global(.menu__list) :global(.menu__list) {
|
|
117
|
-
overflow-y: hidden;
|
|
118
|
-
will-change: height;
|
|
119
|
-
transition: height var(--ifm-transition-fast) linear;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
:global(.menu__list-item--collapsed) :global(.menu__list) {
|
|
123
|
-
height: 0 !important;
|
|
124
|
-
}
|
|
@@ -0,0 +1,181 @@
|
|
|
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, {useEffect, memo} from 'react';
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
import {
|
|
10
|
+
isSamePath,
|
|
11
|
+
usePrevious,
|
|
12
|
+
Collapsible,
|
|
13
|
+
useCollapsible,
|
|
14
|
+
ThemeClassNames,
|
|
15
|
+
} from '@docusaurus/theme-common';
|
|
16
|
+
import Link from '@docusaurus/Link';
|
|
17
|
+
import isInternalUrl from '@docusaurus/isInternalUrl';
|
|
18
|
+
import IconExternalLink from '@theme/IconExternalLink';
|
|
19
|
+
import styles from './styles.module.css';
|
|
20
|
+
|
|
21
|
+
const isActiveSidebarItem = (item, activePath) => {
|
|
22
|
+
if (item.type === 'link') {
|
|
23
|
+
return isSamePath(item.href, activePath);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (item.type === 'category') {
|
|
27
|
+
return item.items.some((subItem) =>
|
|
28
|
+
isActiveSidebarItem(subItem, activePath),
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return false;
|
|
33
|
+
}; // Optimize sidebar at each "level"
|
|
34
|
+
// TODO this item should probably not receive the "activePath" props
|
|
35
|
+
// TODO this triggers whole sidebar re-renders on navigation
|
|
36
|
+
|
|
37
|
+
export const DocSidebarItems = memo(function DocSidebarItems({
|
|
38
|
+
items,
|
|
39
|
+
...props
|
|
40
|
+
}) {
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
{items.map((item, index) => (
|
|
44
|
+
<DocSidebarItem
|
|
45
|
+
key={index} // sidebar is static, the index does not change
|
|
46
|
+
item={item}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
))}
|
|
50
|
+
</>
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
export default function DocSidebarItem({item, ...props}) {
|
|
54
|
+
switch (item.type) {
|
|
55
|
+
case 'category':
|
|
56
|
+
if (item.items.length === 0) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return <DocSidebarItemCategory item={item} {...props} />;
|
|
61
|
+
|
|
62
|
+
case 'link':
|
|
63
|
+
default:
|
|
64
|
+
return <DocSidebarItemLink item={item} {...props} />;
|
|
65
|
+
}
|
|
66
|
+
} // If we navigate to a category and it becomes active, it should automatically expand itself
|
|
67
|
+
|
|
68
|
+
function useAutoExpandActiveCategory({isActive, collapsed, setCollapsed}) {
|
|
69
|
+
const wasActive = usePrevious(isActive);
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const justBecameActive = isActive && !wasActive;
|
|
72
|
+
|
|
73
|
+
if (justBecameActive && collapsed) {
|
|
74
|
+
setCollapsed(false);
|
|
75
|
+
}
|
|
76
|
+
}, [isActive, wasActive, collapsed, setCollapsed]);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function DocSidebarItemCategory({
|
|
80
|
+
item,
|
|
81
|
+
onItemClick,
|
|
82
|
+
activePath,
|
|
83
|
+
level,
|
|
84
|
+
...props
|
|
85
|
+
}) {
|
|
86
|
+
const {items, label, collapsible, className} = item;
|
|
87
|
+
const isActive = isActiveSidebarItem(item, activePath);
|
|
88
|
+
const {collapsed, setCollapsed, toggleCollapsed} = useCollapsible({
|
|
89
|
+
// active categories are always initialized as expanded
|
|
90
|
+
// the default (item.collapsed) is only used for non-active categories
|
|
91
|
+
initialState: () => {
|
|
92
|
+
if (!collapsible) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return isActive ? false : item.collapsed;
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
useAutoExpandActiveCategory({
|
|
100
|
+
isActive,
|
|
101
|
+
collapsed,
|
|
102
|
+
setCollapsed,
|
|
103
|
+
});
|
|
104
|
+
return (
|
|
105
|
+
<li
|
|
106
|
+
className={clsx(
|
|
107
|
+
ThemeClassNames.docs.docSidebarItemCategory,
|
|
108
|
+
ThemeClassNames.docs.docSidebarItemCategoryLevel(level),
|
|
109
|
+
'menu__list-item',
|
|
110
|
+
{
|
|
111
|
+
'menu__list-item--collapsed': collapsed,
|
|
112
|
+
},
|
|
113
|
+
className,
|
|
114
|
+
)}>
|
|
115
|
+
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
116
|
+
<a
|
|
117
|
+
className={clsx('menu__link', {
|
|
118
|
+
'menu__link--sublist': collapsible,
|
|
119
|
+
'menu__link--active': collapsible && isActive,
|
|
120
|
+
[styles.menuLinkText]: !collapsible,
|
|
121
|
+
})}
|
|
122
|
+
onClick={
|
|
123
|
+
collapsible
|
|
124
|
+
? (e) => {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
toggleCollapsed();
|
|
127
|
+
}
|
|
128
|
+
: undefined
|
|
129
|
+
}
|
|
130
|
+
href={collapsible ? '#' : undefined}
|
|
131
|
+
{...props}>
|
|
132
|
+
{label}
|
|
133
|
+
</a>
|
|
134
|
+
|
|
135
|
+
<Collapsible lazy as="ul" className="menu__list" collapsed={collapsed}>
|
|
136
|
+
<DocSidebarItems
|
|
137
|
+
items={items}
|
|
138
|
+
tabIndex={collapsed ? -1 : 0}
|
|
139
|
+
onItemClick={onItemClick}
|
|
140
|
+
activePath={activePath}
|
|
141
|
+
level={level + 1}
|
|
142
|
+
/>
|
|
143
|
+
</Collapsible>
|
|
144
|
+
</li>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function DocSidebarItemLink({item, onItemClick, activePath, level, ...props}) {
|
|
149
|
+
const {href, label, className} = item;
|
|
150
|
+
const isActive = isActiveSidebarItem(item, activePath);
|
|
151
|
+
return (
|
|
152
|
+
<li
|
|
153
|
+
className={clsx(
|
|
154
|
+
ThemeClassNames.docs.docSidebarItemLink,
|
|
155
|
+
ThemeClassNames.docs.docSidebarItemLinkLevel(level),
|
|
156
|
+
'menu__list-item',
|
|
157
|
+
className,
|
|
158
|
+
)}
|
|
159
|
+
key={label}>
|
|
160
|
+
<Link
|
|
161
|
+
className={clsx('menu__link', {
|
|
162
|
+
'menu__link--active': isActive,
|
|
163
|
+
})}
|
|
164
|
+
aria-current={isActive ? 'page' : undefined}
|
|
165
|
+
to={href}
|
|
166
|
+
{...(isInternalUrl(href) && {
|
|
167
|
+
onClick: onItemClick,
|
|
168
|
+
})}
|
|
169
|
+
{...props}>
|
|
170
|
+
{isInternalUrl(href) ? (
|
|
171
|
+
label
|
|
172
|
+
) : (
|
|
173
|
+
<span>
|
|
174
|
+
{label}
|
|
175
|
+
<IconExternalLink />
|
|
176
|
+
</span>
|
|
177
|
+
)}
|
|
178
|
+
</Link>
|
|
179
|
+
</li>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
.menuLinkText {
|
|
10
|
+
cursor: initial;
|
|
11
|
+
}
|
|
12
|
+
.menuLinkText:hover {
|
|
13
|
+
background: none;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
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 Layout from '@theme/Layout';
|
|
9
|
+
import Link from '@docusaurus/Link';
|
|
10
|
+
import {ThemeClassNames, usePluralForm} from '@docusaurus/theme-common';
|
|
11
|
+
import Translate, {translate} from '@docusaurus/Translate';
|
|
12
|
+
|
|
13
|
+
// Very simple pluralization: probably good enough for now
|
|
14
|
+
function useNDocsTaggedPlural() {
|
|
15
|
+
const {selectMessage} = usePluralForm();
|
|
16
|
+
return (count) =>
|
|
17
|
+
selectMessage(
|
|
18
|
+
count,
|
|
19
|
+
translate(
|
|
20
|
+
{
|
|
21
|
+
id: 'theme.docs.tagDocListPageTitle.nDocsTagged',
|
|
22
|
+
description:
|
|
23
|
+
'Pluralized label for "{count} docs tagged". Use as much plural forms (separated by "|") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)',
|
|
24
|
+
message: 'One doc tagged|{count} docs tagged',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
count,
|
|
28
|
+
},
|
|
29
|
+
),
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function DocItem({doc}) {
|
|
34
|
+
return (
|
|
35
|
+
<article className="margin-vert--lg">
|
|
36
|
+
<Link to={doc.permalink}>
|
|
37
|
+
<h2>{doc.title}</h2>
|
|
38
|
+
</Link>
|
|
39
|
+
{doc.description && <p>{doc.description}</p>}
|
|
40
|
+
</article>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default function DocTagDocListPage({tag}) {
|
|
45
|
+
const nDocsTaggedPlural = useNDocsTaggedPlural();
|
|
46
|
+
const title = translate(
|
|
47
|
+
{
|
|
48
|
+
id: 'theme.docs.tagDocListPageTitle',
|
|
49
|
+
description: 'The title of the page for a docs tag',
|
|
50
|
+
message: '{nDocsTagged} with "{tagName}"',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
nDocsTagged: nDocsTaggedPlural(tag.docs.length),
|
|
54
|
+
tagName: tag.name,
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
return (
|
|
58
|
+
<Layout
|
|
59
|
+
title={title}
|
|
60
|
+
wrapperClassName={ThemeClassNames.wrapper.docsPages}
|
|
61
|
+
pageClassName={ThemeClassNames.page.docsTagDocListPage}
|
|
62
|
+
searchMetadatas={{
|
|
63
|
+
// assign unique search tag to exclude this page from search results!
|
|
64
|
+
tag: 'doc_tag_doc_list',
|
|
65
|
+
}}>
|
|
66
|
+
<div className="container margin-vert--lg">
|
|
67
|
+
<div className="row">
|
|
68
|
+
<main className="col col--8 col--offset-2">
|
|
69
|
+
<header className="margin-bottom--xl">
|
|
70
|
+
<h1>{title}</h1>
|
|
71
|
+
<Link href={tag.allTagsPath}>
|
|
72
|
+
<Translate
|
|
73
|
+
id="theme.tags.tagsPageLink"
|
|
74
|
+
description="The label of the link targeting the tag list page">
|
|
75
|
+
View All Tags
|
|
76
|
+
</Translate>
|
|
77
|
+
</Link>
|
|
78
|
+
</header>
|
|
79
|
+
<section className="margin-vert--lg">
|
|
80
|
+
{tag.docs.map((doc) => (
|
|
81
|
+
<DocItem key={doc.id} doc={doc} />
|
|
82
|
+
))}
|
|
83
|
+
</section>
|
|
84
|
+
</main>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
</Layout>
|
|
88
|
+
);
|
|
89
|
+
}
|