@docusaurus/theme-classic 2.0.0-beta.16 → 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 +177 -36
- package/lib/index.js +10 -15
- package/lib/nprogress.css +41 -0
- package/lib/nprogress.js +46 -0
- package/lib/theme-classic.d.ts +600 -76
- package/lib/translations.js +12 -2
- package/lib/validateThemeConfig.js +77 -28
- package/lib-next/theme/BackToTopButton/index.js +6 -104
- package/lib-next/theme/BlogArchivePage/index.js +14 -10
- package/lib-next/theme/BlogLayout/index.js +1 -5
- package/lib-next/theme/BlogListPage/index.js +34 -13
- package/lib-next/theme/BlogListPaginator/index.js +25 -28
- package/lib-next/theme/BlogPostAuthor/index.js +16 -7
- package/lib-next/theme/BlogPostItem/index.js +6 -6
- package/lib-next/theme/BlogPostItem/styles.module.css +9 -0
- package/lib-next/theme/BlogPostPage/index.js +56 -45
- 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 +17 -14
- package/lib-next/theme/BlogTagsPostsPage/index.js +43 -38
- 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/lib-next/theme/CodeBlock/{styles.module.css → Content/styles.module.css} +39 -29
- package/lib-next/theme/CodeBlock/CopyButton/index.js +61 -0
- package/lib-next/theme/CodeBlock/CopyButton/styles.module.css +47 -0
- 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 +26 -164
- package/lib-next/theme/ColorModeToggle/index.js +62 -0
- package/lib-next/theme/ColorModeToggle/styles.module.css +35 -0
- package/lib-next/theme/Details/index.js +1 -1
- package/lib-next/theme/DocBreadcrumbs/index.js +63 -19
- package/lib-next/theme/DocBreadcrumbs/styles.module.css +8 -15
- package/lib-next/theme/DocCard/index.js +17 -15
- package/lib-next/theme/DocCard/styles.module.css +8 -17
- package/lib-next/theme/DocCardList/index.js +20 -6
- package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +30 -9
- package/lib-next/theme/DocCategoryGeneratedIndexPage/styles.module.css +8 -0
- package/lib-next/theme/DocItem/index.js +85 -67
- 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 +30 -149
- package/lib-next/theme/DocPaginator/index.js +25 -28
- package/lib-next/theme/DocSidebar/Desktop/CollapseButton/index.js +34 -0
- package/lib-next/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +46 -0
- package/lib-next/theme/DocSidebar/Desktop/Content/index.js +46 -0
- package/lib-next/theme/DocSidebar/Desktop/Content/styles.module.css +23 -0
- package/lib-next/theme/DocSidebar/Desktop/index.js +36 -0
- package/lib-next/theme/DocSidebar/Desktop/styles.module.css +50 -0
- package/lib-next/theme/DocSidebar/Mobile/index.js +49 -0
- package/lib-next/theme/DocSidebar/index.js +6 -113
- package/lib-next/theme/DocSidebarItem/Category.js +197 -0
- package/lib-next/theme/DocSidebarItem/Html.js +27 -0
- package/lib-next/theme/DocSidebarItem/{styles.module.css → Html.module.css} +0 -0
- package/lib-next/theme/DocSidebarItem/Link.js +53 -0
- package/lib-next/theme/DocSidebarItem/Link.module.css +10 -0
- package/lib-next/theme/DocSidebarItem/index.js +4 -245
- package/lib-next/theme/DocSidebarItems/index.js +1 -6
- package/lib-next/theme/DocTagDocListPage/index.js +40 -33
- package/lib-next/theme/DocTagsListPage/index.js +21 -16
- package/lib-next/theme/DocVersionBanner/index.js +2 -2
- package/lib-next/theme/Footer/Copyright/index.js +18 -0
- package/lib-next/theme/Footer/Layout/index.js +26 -0
- package/lib-next/theme/Footer/LinkItem/index.js +33 -0
- package/lib-next/theme/Footer/Links/MultiColumn/index.js +47 -0
- package/lib-next/theme/Footer/Links/Simple/index.js +41 -0
- package/lib-next/theme/Footer/Links/index.js +17 -0
- package/lib-next/theme/Footer/Logo/index.js +38 -0
- package/lib-next/theme/Footer/{styles.module.css → Logo/styles.module.css} +0 -0
- package/lib-next/theme/Footer/index.js +11 -163
- package/lib-next/theme/Heading/index.js +10 -24
- package/lib-next/theme/IconDarkMode/index.js +17 -0
- package/lib-next/theme/IconExternalLink/styles.module.css +0 -2
- package/lib-next/theme/IconHome/index.js +17 -0
- package/lib-next/theme/IconLanguage/index.js +3 -3
- package/lib-next/theme/IconLightMode/index.js +17 -0
- package/lib-next/theme/LastUpdated/index.js +1 -0
- package/lib-next/theme/Layout/index.js +15 -10
- package/lib-next/theme/LayoutProviders/index.js +5 -4
- package/lib-next/theme/MDXComponents/A.js +11 -0
- package/lib-next/theme/MDXComponents/Code.js +28 -0
- package/lib-next/theme/MDXComponents/Details.js +20 -0
- package/lib-next/theme/MDXComponents/Head.js +26 -0
- package/lib-next/theme/MDXComponents/Heading.js +11 -0
- package/lib-next/theme/MDXComponents/Img.js +24 -0
- package/{src/theme/MDXComponents/styles.css → lib-next/theme/MDXComponents/Img.module.css} +1 -6
- package/lib-next/theme/MDXComponents/Pre.js +18 -0
- package/lib-next/theme/MDXComponents/Ul.js +21 -0
- package/lib-next/theme/MDXComponents/index.js +22 -57
- package/lib-next/theme/MDXContent/index.js +12 -0
- package/lib-next/theme/MDXPage/index.js +33 -28
- package/lib-next/theme/Navbar/ColorModeToggle/index.js +25 -0
- package/lib-next/theme/Navbar/Content/index.js +75 -0
- package/lib-next/theme/Navbar/Content/styles.module.css +15 -0
- package/lib-next/theme/Navbar/Layout/index.js +54 -0
- package/{src/theme/Navbar → lib-next/theme/Navbar/Layout}/styles.module.css +0 -13
- package/lib-next/theme/Navbar/Logo/index.js +17 -0
- package/lib-next/theme/Navbar/MobileSidebar/Header/index.js +33 -0
- package/lib-next/theme/Navbar/MobileSidebar/Layout/index.js +28 -0
- package/lib-next/theme/Navbar/MobileSidebar/PrimaryMenu/index.js +33 -0
- package/lib-next/theme/Navbar/MobileSidebar/SecondaryMenu/index.js +36 -0
- package/lib-next/theme/Navbar/MobileSidebar/Toggle/index.js +23 -0
- package/lib-next/theme/Navbar/MobileSidebar/index.js +31 -0
- 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/Navbar/index.js +6 -271
- package/lib-next/theme/NavbarItem/ComponentTypes.js +27 -0
- package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +2 -6
- 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 +14 -3
- 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 -35
- 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/NotFound.js +38 -33
- package/lib-next/theme/PaginatorNavLink/index.js +8 -2
- package/lib-next/theme/SearchMetadata/index.js +9 -0
- package/lib-next/theme/{LayoutHead → SiteMetadata}/index.js +19 -33
- 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 +4 -16
- 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/TabItem/styles.module.css +10 -0
- package/lib-next/theme/Tabs/__tests__/index.test.js +8 -8
- package/lib-next/theme/Tabs/index.js +5 -5
- package/lib-next/theme/Tabs/styles.module.css +4 -0
- package/lib-next/theme/Tag/index.js +6 -7
- package/lib-next/theme/TagsListInline/index.js +1 -1
- package/lib-next/theme/ThemedImage/index.js +3 -3
- package/package.json +25 -20
- package/src/admonitions.css +4 -0
- package/src/getSwizzleConfig.ts +173 -22
- package/src/index.ts +14 -15
- package/src/nprogress.css +41 -0
- package/src/nprogress.ts +31 -0
- package/src/theme/BackToTopButton/index.tsx +5 -114
- package/src/theme/BlogArchivePage/index.tsx +18 -17
- package/src/theme/BlogLayout/index.tsx +1 -5
- package/src/theme/BlogListPage/index.tsx +32 -13
- package/src/theme/BlogListPaginator/index.tsx +25 -28
- package/src/theme/BlogPostAuthor/index.tsx +14 -8
- package/src/theme/BlogPostItem/index.tsx +6 -6
- package/src/theme/BlogPostItem/styles.module.css +9 -0
- package/src/theme/BlogPostPage/index.tsx +55 -48
- 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 +17 -14
- package/src/theme/BlogTagsPostsPage/index.tsx +46 -36
- 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/src/theme/CodeBlock/{styles.module.css → Content/styles.module.css} +39 -29
- package/src/theme/CodeBlock/CopyButton/index.tsx +67 -0
- package/src/theme/CodeBlock/CopyButton/styles.module.css +47 -0
- 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 -165
- package/src/theme/ColorModeToggle/index.tsx +67 -0
- package/src/theme/ColorModeToggle/styles.module.css +35 -0
- package/src/theme/Details/index.tsx +1 -1
- package/src/theme/DocBreadcrumbs/index.tsx +65 -16
- package/src/theme/DocBreadcrumbs/styles.module.css +8 -15
- package/src/theme/DocCard/index.tsx +24 -17
- package/src/theme/DocCard/styles.module.css +8 -17
- package/src/theme/DocCardList/index.tsx +19 -10
- package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +34 -7
- package/src/theme/DocCategoryGeneratedIndexPage/styles.module.css +8 -0
- package/src/theme/DocItem/index.tsx +72 -56
- 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 +30 -160
- package/src/theme/DocPaginator/index.tsx +25 -28
- package/src/theme/DocSidebar/Desktop/CollapseButton/index.tsx +38 -0
- package/src/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +46 -0
- package/src/theme/DocSidebar/Desktop/Content/index.tsx +55 -0
- package/src/theme/DocSidebar/Desktop/Content/styles.module.css +23 -0
- package/src/theme/DocSidebar/Desktop/index.tsx +40 -0
- package/src/theme/DocSidebar/Desktop/styles.module.css +50 -0
- package/src/theme/DocSidebar/Mobile/index.tsx +54 -0
- package/src/theme/DocSidebar/index.tsx +6 -121
- package/src/theme/DocSidebarItem/Category.tsx +210 -0
- package/src/theme/DocSidebarItem/{styles.module.css → Html.module.css} +0 -0
- 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 -260
- package/src/theme/DocSidebarItems/index.tsx +1 -6
- package/src/theme/DocTagDocListPage/index.tsx +40 -33
- package/src/theme/DocTagsListPage/index.tsx +21 -16
- package/src/theme/DocVersionBanner/index.tsx +5 -6
- package/src/theme/Footer/Copyright/index.tsx +20 -0
- package/src/theme/Footer/Layout/index.tsx +34 -0
- package/src/theme/Footer/LinkItem/index.tsx +36 -0
- package/src/theme/Footer/Links/MultiColumn/index.tsx +51 -0
- package/src/theme/Footer/Links/Simple/index.tsx +42 -0
- package/src/theme/Footer/Links/index.tsx +21 -0
- package/src/theme/Footer/Logo/index.tsx +41 -0
- package/src/theme/Footer/{styles.module.css → Logo/styles.module.css} +0 -0
- package/src/theme/Footer/index.tsx +12 -186
- package/src/theme/Heading/index.tsx +10 -22
- package/src/theme/IconDarkMode/index.tsx +20 -0
- package/src/theme/IconExternalLink/styles.module.css +0 -2
- package/src/theme/IconHome/index.tsx +20 -0
- package/src/theme/IconLanguage/index.tsx +3 -3
- package/src/theme/IconLightMode/index.tsx +20 -0
- package/src/theme/LastUpdated/index.tsx +1 -0
- package/src/theme/Layout/index.tsx +15 -10
- package/src/theme/LayoutProviders/index.tsx +5 -4
- package/src/theme/MDXComponents/A.tsx +14 -0
- package/src/theme/MDXComponents/Code.tsx +37 -0
- package/src/theme/MDXComponents/Details.tsx +25 -0
- package/src/theme/MDXComponents/Head.tsx +29 -0
- package/src/theme/MDXComponents/Heading.tsx +14 -0
- package/{lib-next/theme/MDXComponents/styles.css → src/theme/MDXComponents/Img.module.css} +1 -6
- package/src/theme/MDXComponents/Img.tsx +26 -0
- package/src/theme/MDXComponents/Pre.tsx +22 -0
- package/src/theme/MDXComponents/Ul.tsx +24 -0
- package/src/theme/MDXComponents/index.tsx +23 -66
- package/src/theme/MDXContent/index.tsx +15 -0
- package/src/theme/MDXPage/index.tsx +33 -28
- package/src/theme/Navbar/ColorModeToggle/index.tsx +30 -0
- package/src/theme/Navbar/Content/index.tsx +86 -0
- package/src/theme/Navbar/Content/styles.module.css +15 -0
- package/src/theme/Navbar/Layout/index.tsx +57 -0
- package/{lib-next/theme/Navbar → src/theme/Navbar/Layout}/styles.module.css +0 -13
- package/src/theme/Navbar/Logo/index.tsx +19 -0
- package/src/theme/Navbar/MobileSidebar/Header/index.tsx +34 -0
- package/src/theme/Navbar/MobileSidebar/Layout/index.tsx +31 -0
- package/src/theme/Navbar/MobileSidebar/PrimaryMenu/index.tsx +38 -0
- package/src/theme/Navbar/MobileSidebar/SecondaryMenu/index.tsx +38 -0
- package/src/theme/Navbar/MobileSidebar/Toggle/index.tsx +25 -0
- package/src/theme/Navbar/MobileSidebar/index.tsx +33 -0
- package/src/theme/Navbar/Search/index.tsx +15 -0
- package/src/theme/Navbar/Search/styles.module.css +20 -0
- package/src/theme/Navbar/index.tsx +6 -286
- package/src/theme/NavbarItem/ComponentTypes.tsx +32 -0
- package/src/theme/NavbarItem/DefaultNavbarItem.tsx +2 -2
- 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 +15 -3
- package/src/theme/NavbarItem/HtmlNavbarItem.tsx +32 -0
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +5 -9
- package/src/theme/NavbarItem/NavbarNavLink.tsx +41 -29
- package/src/theme/NavbarItem/SearchNavbarItem.tsx +6 -1
- package/src/theme/NavbarItem/index.tsx +9 -39
- package/src/theme/NavbarItem/utils.ts +5 -2
- package/src/theme/NotFound.tsx +38 -33
- package/src/theme/PaginatorNavLink/index.tsx +8 -2
- package/src/theme/SearchMetadata/index.tsx +9 -0
- package/src/theme/{LayoutHead → SiteMetadata}/index.tsx +19 -33
- 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 +4 -17
- 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 +8 -9
- package/src/theme/Tabs/styles.module.css +4 -0
- package/src/theme/Tag/index.tsx +6 -8
- package/src/theme/TagsListInline/index.tsx +1 -1
- package/src/theme/ThemedImage/index.tsx +4 -3
- package/src/theme-classic.d.ts +600 -76
- package/src/translations.ts +12 -6
- package/src/validateThemeConfig.ts +90 -39
- package/lib/types.d.ts +0 -11
- package/lib-next/theme/DocPage/styles.module.css +0 -86
- package/lib-next/theme/DocSidebar/styles.module.css +0 -107
- package/lib-next/theme/Seo/index.js +0 -40
- package/lib-next/theme/Toggle/index.js +0 -100
- package/lib-next/theme/Toggle/styles.module.css +0 -106
- package/src/theme/DocPage/styles.module.css +0 -86
- package/src/theme/DocSidebar/styles.module.css +0 -107
- package/src/theme/Seo/index.tsx +0 -49
- package/src/theme/Toggle/index.tsx +0 -117
- package/src/theme/Toggle/styles.module.css +0 -106
- package/src/types.d.ts +0 -11
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
:global(.theme-code-block:hover) .copyButtonCopied {
|
|
9
|
+
opacity: 1 !important;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.copyButtonIcons {
|
|
13
|
+
position: relative;
|
|
14
|
+
width: 1.125rem;
|
|
15
|
+
height: 1.125rem;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.copyButtonIcon,
|
|
19
|
+
.copyButtonSuccessIcon {
|
|
20
|
+
position: absolute;
|
|
21
|
+
top: 0;
|
|
22
|
+
left: 0;
|
|
23
|
+
fill: currentColor;
|
|
24
|
+
opacity: inherit;
|
|
25
|
+
width: inherit;
|
|
26
|
+
height: inherit;
|
|
27
|
+
transition: all 0.15s ease;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.copyButtonSuccessIcon {
|
|
31
|
+
top: 50%;
|
|
32
|
+
left: 50%;
|
|
33
|
+
transform: translate(-50%, -50%) scale(0.33);
|
|
34
|
+
opacity: 0;
|
|
35
|
+
color: #00d600;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.copyButtonCopied .copyButtonIcon {
|
|
39
|
+
transform: scale(0.33);
|
|
40
|
+
opacity: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.copyButtonCopied .copyButtonSuccessIcon {
|
|
44
|
+
transform: translate(-50%, -50%) scale(1);
|
|
45
|
+
opacity: 1;
|
|
46
|
+
transition-delay: 0.075s;
|
|
47
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 clsx from 'clsx';
|
|
10
|
+
import type {Props} from '@theme/CodeBlock/Line';
|
|
11
|
+
import styles from './styles.module.css';
|
|
12
|
+
|
|
13
|
+
export default function CodeBlockLine({
|
|
14
|
+
line,
|
|
15
|
+
classNames,
|
|
16
|
+
showLineNumbers,
|
|
17
|
+
getLineProps,
|
|
18
|
+
getTokenProps,
|
|
19
|
+
}: Props): JSX.Element {
|
|
20
|
+
if (line.length === 1 && line[0]!.content === '\n') {
|
|
21
|
+
line[0]!.content = '';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const lineProps = getLineProps({
|
|
25
|
+
line,
|
|
26
|
+
className: clsx(classNames, showLineNumbers && styles.codeLine),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const lineTokens = line.map((token, key) => (
|
|
30
|
+
<span key={key} {...getTokenProps({token, key})} />
|
|
31
|
+
));
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<span {...lineProps}>
|
|
35
|
+
{showLineNumbers ? (
|
|
36
|
+
<>
|
|
37
|
+
<span className={styles.codeLineNumber} />
|
|
38
|
+
<span className={styles.codeLineContent}>{lineTokens}</span>
|
|
39
|
+
</>
|
|
40
|
+
) : (
|
|
41
|
+
<>
|
|
42
|
+
{lineTokens}
|
|
43
|
+
<br />
|
|
44
|
+
</>
|
|
45
|
+
)}
|
|
46
|
+
</span>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
:global(.theme-code-block-highlighted-line) {
|
|
9
|
+
background-color: var(--docusaurus-highlighted-code-line-bg);
|
|
10
|
+
display: block;
|
|
11
|
+
margin: 0 calc(-1 * var(--ifm-pre-padding));
|
|
12
|
+
padding: 0 var(--ifm-pre-padding);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/* Intentionally has zero specificity, so that to be able to override
|
|
16
|
+
the background in custom CSS file due bug https://github.com/facebook/docusaurus/issues/3678 */
|
|
17
|
+
:where(:root) {
|
|
18
|
+
--docusaurus-highlighted-code-line-bg: rgb(72 77 91);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
:where([data-theme='dark']) {
|
|
22
|
+
--docusaurus-highlighted-code-line-bg: rgb(100 100 100);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.codeLine {
|
|
26
|
+
display: table-row;
|
|
27
|
+
counter-increment: line-count;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.codeLineNumber {
|
|
31
|
+
display: table-cell;
|
|
32
|
+
text-align: right;
|
|
33
|
+
width: 1%;
|
|
34
|
+
position: sticky;
|
|
35
|
+
left: 0;
|
|
36
|
+
padding: 0 var(--ifm-pre-padding);
|
|
37
|
+
background: var(--ifm-pre-background);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.codeLineNumber::before {
|
|
41
|
+
content: counter(line-count);
|
|
42
|
+
opacity: 0.4;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.highlightedCodeLine .codeLineNumber::before {
|
|
46
|
+
opacity: 0.8;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.codeLineContent {
|
|
50
|
+
padding-right: var(--ifm-pre-padding);
|
|
51
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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 clsx from 'clsx';
|
|
10
|
+
import {translate} from '@docusaurus/Translate';
|
|
11
|
+
import type {Props} from '@theme/CodeBlock/WordWrapButton';
|
|
12
|
+
|
|
13
|
+
import styles from './styles.module.css';
|
|
14
|
+
|
|
15
|
+
export default function WordWrapButton({
|
|
16
|
+
className,
|
|
17
|
+
onClick,
|
|
18
|
+
isEnabled,
|
|
19
|
+
}: Props): JSX.Element | null {
|
|
20
|
+
const title = translate({
|
|
21
|
+
id: 'theme.CodeBlock.wordWrapToggle',
|
|
22
|
+
message: 'Toggle word wrap',
|
|
23
|
+
description:
|
|
24
|
+
'The title attribute for toggle word wrapping button of code block lines',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<button
|
|
29
|
+
type="button"
|
|
30
|
+
onClick={onClick}
|
|
31
|
+
className={clsx(
|
|
32
|
+
'clean-btn',
|
|
33
|
+
className,
|
|
34
|
+
isEnabled && styles.wordWrapButtonEnabled,
|
|
35
|
+
)}
|
|
36
|
+
aria-label={title}
|
|
37
|
+
title={title}>
|
|
38
|
+
<svg
|
|
39
|
+
className={styles.wordWrapButtonIcon}
|
|
40
|
+
viewBox="0 0 24 24"
|
|
41
|
+
aria-hidden="true">
|
|
42
|
+
<path
|
|
43
|
+
fill="currentColor"
|
|
44
|
+
d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3l3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"
|
|
45
|
+
/>
|
|
46
|
+
</svg>
|
|
47
|
+
</button>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -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
|
+
.wordWrapButtonIcon {
|
|
9
|
+
width: 1.2rem;
|
|
10
|
+
height: 1.2rem;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.wordWrapButtonEnabled .wordWrapButtonIcon {
|
|
14
|
+
color: var(--ifm-color-primary);
|
|
15
|
+
}
|
|
@@ -5,177 +5,41 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React, {isValidElement,
|
|
9
|
-
import
|
|
10
|
-
import Highlight, {defaultProps, type Language} from 'prism-react-renderer';
|
|
11
|
-
import copy from 'copy-text-to-clipboard';
|
|
12
|
-
import Translate, {translate} from '@docusaurus/Translate';
|
|
13
|
-
import {
|
|
14
|
-
useThemeConfig,
|
|
15
|
-
parseCodeBlockTitle,
|
|
16
|
-
parseLanguage,
|
|
17
|
-
parseLines,
|
|
18
|
-
ThemeClassNames,
|
|
19
|
-
usePrismTheme,
|
|
20
|
-
} from '@docusaurus/theme-common';
|
|
8
|
+
import React, {isValidElement, type ReactNode} from 'react';
|
|
9
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
21
10
|
import type {Props} from '@theme/CodeBlock';
|
|
11
|
+
import ElementContent from '@theme/CodeBlock/Content/Element';
|
|
12
|
+
import StringContent from '@theme/CodeBlock/Content/String';
|
|
22
13
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
language: languageProp,
|
|
31
|
-
}: Props): JSX.Element {
|
|
32
|
-
const {prism} = useThemeConfig();
|
|
33
|
-
|
|
34
|
-
const [showCopied, setShowCopied] = useState(false);
|
|
35
|
-
const [mounted, setMounted] = useState(false);
|
|
36
|
-
// The Prism theme on SSR is always the default theme but the site theme
|
|
37
|
-
// can be in a different mode. React hydration doesn't update DOM styles
|
|
38
|
-
// that come from SSR. Hence force a re-render after mounting to apply the
|
|
39
|
-
// current relevant styles. There will be a flash seen of the original
|
|
40
|
-
// styles seen using this current approach but that's probably ok. Fixing
|
|
41
|
-
// the flash will require changing the theming approach and is not worth it
|
|
42
|
-
// at this point.
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
setMounted(true);
|
|
45
|
-
}, []);
|
|
46
|
-
|
|
47
|
-
// We still parse the metastring in case we want to support more syntax in the
|
|
48
|
-
// future. Note that MDX doesn't strip quotes when parsing metastring:
|
|
49
|
-
// "title=\"xyz\"" => title: "\"xyz\""
|
|
50
|
-
const codeBlockTitle = parseCodeBlockTitle(metastring) || title;
|
|
51
|
-
const prismTheme = usePrismTheme();
|
|
52
|
-
|
|
53
|
-
// <pre> tags in markdown map to CodeBlocks and they may contain JSX children.
|
|
54
|
-
// When the children is not a simple string, we just return a styled block
|
|
55
|
-
// without actually highlighting.
|
|
14
|
+
/**
|
|
15
|
+
* Best attempt to make the children a plain string so it is copyable. If there
|
|
16
|
+
* are react elements, we will not be able to copy the content, and it will
|
|
17
|
+
* return `children` as-is; otherwise, it concatenates the string children
|
|
18
|
+
* together.
|
|
19
|
+
*/
|
|
20
|
+
function maybeStringifyChildren(children: ReactNode): ReactNode {
|
|
56
21
|
if (React.Children.toArray(children).some((el) => isValidElement(el))) {
|
|
57
|
-
return
|
|
58
|
-
<Highlight
|
|
59
|
-
{...defaultProps}
|
|
60
|
-
key={String(mounted)}
|
|
61
|
-
theme={prismTheme}
|
|
62
|
-
code=""
|
|
63
|
-
language={'text' as Language}>
|
|
64
|
-
{({className, style}) => (
|
|
65
|
-
<pre
|
|
66
|
-
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
|
|
67
|
-
tabIndex={0}
|
|
68
|
-
className={clsx(
|
|
69
|
-
className,
|
|
70
|
-
styles.codeBlockStandalone,
|
|
71
|
-
'thin-scrollbar',
|
|
72
|
-
styles.codeBlockContainer,
|
|
73
|
-
blockClassName,
|
|
74
|
-
ThemeClassNames.common.codeBlock,
|
|
75
|
-
)}
|
|
76
|
-
style={style}>
|
|
77
|
-
<code className={styles.codeBlockLines}>{children}</code>
|
|
78
|
-
</pre>
|
|
79
|
-
)}
|
|
80
|
-
</Highlight>
|
|
81
|
-
);
|
|
22
|
+
return children;
|
|
82
23
|
}
|
|
83
|
-
|
|
84
24
|
// The children is now guaranteed to be one/more plain strings
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
: (children as string);
|
|
88
|
-
|
|
89
|
-
const language =
|
|
90
|
-
languageProp ?? parseLanguage(blockClassName) ?? prism.defaultLanguage;
|
|
91
|
-
const {highlightLines, code} = parseLines(content, metastring, language);
|
|
92
|
-
|
|
93
|
-
const handleCopyCode = () => {
|
|
94
|
-
copy(code);
|
|
95
|
-
setShowCopied(true);
|
|
96
|
-
|
|
97
|
-
setTimeout(() => setShowCopied(false), 2000);
|
|
98
|
-
};
|
|
25
|
+
return Array.isArray(children) ? children.join('') : (children as string);
|
|
26
|
+
}
|
|
99
27
|
|
|
28
|
+
export default function CodeBlock({
|
|
29
|
+
children: rawChildren,
|
|
30
|
+
...props
|
|
31
|
+
}: Props): JSX.Element {
|
|
32
|
+
// The Prism theme on SSR is always the default theme but the site theme can
|
|
33
|
+
// be in a different mode. React hydration doesn't update DOM styles that come
|
|
34
|
+
// from SSR. Hence force a re-render after mounting to apply the current
|
|
35
|
+
// relevant styles.
|
|
36
|
+
const isBrowser = useIsBrowser();
|
|
37
|
+
const children = maybeStringifyChildren(rawChildren);
|
|
38
|
+
const CodeBlockComp =
|
|
39
|
+
typeof children === 'string' ? StringContent : ElementContent;
|
|
100
40
|
return (
|
|
101
|
-
<
|
|
102
|
-
{
|
|
103
|
-
|
|
104
|
-
theme={prismTheme}
|
|
105
|
-
code={code}
|
|
106
|
-
language={(language ?? 'text') as Language}>
|
|
107
|
-
{({className, style, tokens, getLineProps, getTokenProps}) => (
|
|
108
|
-
<div
|
|
109
|
-
className={clsx(
|
|
110
|
-
styles.codeBlockContainer,
|
|
111
|
-
blockClassName,
|
|
112
|
-
{
|
|
113
|
-
[`language-${language}`]:
|
|
114
|
-
language && !blockClassName.includes(`language-${language}`),
|
|
115
|
-
},
|
|
116
|
-
ThemeClassNames.common.codeBlock,
|
|
117
|
-
)}>
|
|
118
|
-
{codeBlockTitle && (
|
|
119
|
-
<div style={style} className={styles.codeBlockTitle}>
|
|
120
|
-
{codeBlockTitle}
|
|
121
|
-
</div>
|
|
122
|
-
)}
|
|
123
|
-
<div className={clsx(styles.codeBlockContent, language)}>
|
|
124
|
-
<pre
|
|
125
|
-
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
|
|
126
|
-
tabIndex={0}
|
|
127
|
-
className={clsx(className, styles.codeBlock, 'thin-scrollbar')}
|
|
128
|
-
style={style}>
|
|
129
|
-
<code className={styles.codeBlockLines}>
|
|
130
|
-
{tokens.map((line, i) => {
|
|
131
|
-
if (line.length === 1 && line[0].content === '\n') {
|
|
132
|
-
line[0].content = '';
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const lineProps = getLineProps({line, key: i});
|
|
136
|
-
|
|
137
|
-
if (highlightLines.includes(i)) {
|
|
138
|
-
lineProps.className += ' docusaurus-highlight-code-line';
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<span key={i} {...lineProps}>
|
|
143
|
-
{line.map((token, key) => (
|
|
144
|
-
<span key={key} {...getTokenProps({token, key})} />
|
|
145
|
-
))}
|
|
146
|
-
<br />
|
|
147
|
-
</span>
|
|
148
|
-
);
|
|
149
|
-
})}
|
|
150
|
-
</code>
|
|
151
|
-
</pre>
|
|
152
|
-
|
|
153
|
-
<button
|
|
154
|
-
type="button"
|
|
155
|
-
aria-label={translate({
|
|
156
|
-
id: 'theme.CodeBlock.copyButtonAriaLabel',
|
|
157
|
-
message: 'Copy code to clipboard',
|
|
158
|
-
description: 'The ARIA label for copy code blocks button',
|
|
159
|
-
})}
|
|
160
|
-
className={clsx(styles.copyButton, 'clean-btn')}
|
|
161
|
-
onClick={handleCopyCode}>
|
|
162
|
-
{showCopied ? (
|
|
163
|
-
<Translate
|
|
164
|
-
id="theme.CodeBlock.copied"
|
|
165
|
-
description="The copied button label on code blocks">
|
|
166
|
-
Copied
|
|
167
|
-
</Translate>
|
|
168
|
-
) : (
|
|
169
|
-
<Translate
|
|
170
|
-
id="theme.CodeBlock.copy"
|
|
171
|
-
description="The copy button label on code blocks">
|
|
172
|
-
Copy
|
|
173
|
-
</Translate>
|
|
174
|
-
)}
|
|
175
|
-
</button>
|
|
176
|
-
</div>
|
|
177
|
-
</div>
|
|
178
|
-
)}
|
|
179
|
-
</Highlight>
|
|
41
|
+
<CodeBlockComp key={String(isBrowser)} {...props}>
|
|
42
|
+
{children as string}
|
|
43
|
+
</CodeBlockComp>
|
|
180
44
|
);
|
|
181
45
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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/ColorModeToggle';
|
|
10
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
11
|
+
import {translate} from '@docusaurus/Translate';
|
|
12
|
+
import IconLightMode from '@theme/IconLightMode';
|
|
13
|
+
import IconDarkMode from '@theme/IconDarkMode';
|
|
14
|
+
|
|
15
|
+
import clsx from 'clsx';
|
|
16
|
+
import styles from './styles.module.css';
|
|
17
|
+
|
|
18
|
+
function ColorModeToggle({className, value, onChange}: Props): JSX.Element {
|
|
19
|
+
const isBrowser = useIsBrowser();
|
|
20
|
+
|
|
21
|
+
const title = translate(
|
|
22
|
+
{
|
|
23
|
+
message: 'Switch between dark and light mode (currently {mode})',
|
|
24
|
+
id: 'theme.colorToggle.ariaLabel',
|
|
25
|
+
description: 'The ARIA label for the navbar color mode toggle',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
mode:
|
|
29
|
+
value === 'dark'
|
|
30
|
+
? translate({
|
|
31
|
+
message: 'dark mode',
|
|
32
|
+
id: 'theme.colorToggle.ariaLabel.mode.dark',
|
|
33
|
+
description: 'The name for the dark color mode',
|
|
34
|
+
})
|
|
35
|
+
: translate({
|
|
36
|
+
message: 'light mode',
|
|
37
|
+
id: 'theme.colorToggle.ariaLabel.mode.light',
|
|
38
|
+
description: 'The name for the light color mode',
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div className={clsx(styles.toggle, className)}>
|
|
45
|
+
<button
|
|
46
|
+
className={clsx(
|
|
47
|
+
'clean-btn',
|
|
48
|
+
styles.toggleButton,
|
|
49
|
+
!isBrowser && styles.toggleButtonDisabled,
|
|
50
|
+
)}
|
|
51
|
+
type="button"
|
|
52
|
+
onClick={() => onChange(value === 'dark' ? 'light' : 'dark')}
|
|
53
|
+
disabled={!isBrowser}
|
|
54
|
+
title={title}
|
|
55
|
+
aria-label={title}>
|
|
56
|
+
<IconLightMode
|
|
57
|
+
className={clsx(styles.toggleIcon, styles.lightToggleIcon)}
|
|
58
|
+
/>
|
|
59
|
+
<IconDarkMode
|
|
60
|
+
className={clsx(styles.toggleIcon, styles.darkToggleIcon)}
|
|
61
|
+
/>
|
|
62
|
+
</button>
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default React.memo(ColorModeToggle);
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
.toggle {
|
|
9
|
+
width: 2rem;
|
|
10
|
+
height: 2rem;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.toggleButton {
|
|
14
|
+
-webkit-tap-highlight-color: transparent;
|
|
15
|
+
align-items: center;
|
|
16
|
+
display: flex;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
border-radius: 50%;
|
|
21
|
+
transition: background var(--ifm-transition-fast);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.toggleButton:hover {
|
|
25
|
+
background: var(--ifm-color-emphasis-200);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
[data-theme='light'] .darkToggleIcon,
|
|
29
|
+
[data-theme='dark'] .lightToggleIcon {
|
|
30
|
+
display: none;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.toggleButtonDisabled {
|
|
34
|
+
cursor: not-allowed;
|
|
35
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
|
-
import {Details as DetailsGeneric} from '@docusaurus/theme-common';
|
|
10
|
+
import {Details as DetailsGeneric} from '@docusaurus/theme-common/Details';
|
|
11
11
|
import type {Props} from '@theme/Details';
|
|
12
12
|
import styles from './styles.module.css';
|
|
13
13
|
|
|
@@ -15,21 +15,37 @@ import styles from './styles.module.css';
|
|
|
15
15
|
import clsx from 'clsx';
|
|
16
16
|
import Link from '@docusaurus/Link';
|
|
17
17
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
18
|
+
import {translate} from '@docusaurus/Translate';
|
|
19
|
+
import IconHome from '@theme/IconHome';
|
|
18
20
|
|
|
19
21
|
// TODO move to design system folder
|
|
20
22
|
function BreadcrumbsItemLink({
|
|
21
23
|
children,
|
|
22
24
|
href,
|
|
25
|
+
isLast,
|
|
23
26
|
}: {
|
|
24
27
|
children: ReactNode;
|
|
25
|
-
href
|
|
28
|
+
href: string | undefined;
|
|
29
|
+
isLast: boolean;
|
|
26
30
|
}): JSX.Element {
|
|
27
|
-
const className =
|
|
31
|
+
const className = 'breadcrumbs__link';
|
|
32
|
+
if (isLast) {
|
|
33
|
+
return (
|
|
34
|
+
<span className={className} itemProp="name">
|
|
35
|
+
{children}
|
|
36
|
+
</span>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
28
39
|
return href ? (
|
|
29
|
-
<Link className={className} href={href}>
|
|
30
|
-
{children}
|
|
40
|
+
<Link className={className} href={href} itemProp="item">
|
|
41
|
+
<span itemProp="name">{children}</span>
|
|
31
42
|
</Link>
|
|
32
43
|
) : (
|
|
44
|
+
// TODO Google search console doesn't like breadcrumb items without href.
|
|
45
|
+
// The schema doesn't seem to require `id` for each `item`, although Google
|
|
46
|
+
// insist to infer one, even if it's invalid. Removing `itemProp="item
|
|
47
|
+
// name"` for now, since I don't know how to properly fix it.
|
|
48
|
+
// See https://github.com/facebook/docusaurus/issues/7241
|
|
33
49
|
<span className={className}>{children}</span>
|
|
34
50
|
);
|
|
35
51
|
}
|
|
@@ -38,16 +54,26 @@ function BreadcrumbsItemLink({
|
|
|
38
54
|
function BreadcrumbsItem({
|
|
39
55
|
children,
|
|
40
56
|
active,
|
|
57
|
+
index,
|
|
58
|
+
addMicrodata,
|
|
41
59
|
}: {
|
|
42
60
|
children: ReactNode;
|
|
43
61
|
active?: boolean;
|
|
62
|
+
index: number;
|
|
63
|
+
addMicrodata: boolean;
|
|
44
64
|
}): JSX.Element {
|
|
45
65
|
return (
|
|
46
66
|
<li
|
|
67
|
+
{...(addMicrodata && {
|
|
68
|
+
itemScope: true,
|
|
69
|
+
itemProp: 'itemListElement',
|
|
70
|
+
itemType: 'https://schema.org/ListItem',
|
|
71
|
+
})}
|
|
47
72
|
className={clsx('breadcrumbs__item', {
|
|
48
73
|
'breadcrumbs__item--active': active,
|
|
49
74
|
})}>
|
|
50
75
|
{children}
|
|
76
|
+
<meta itemProp="position" content={String(index + 1)} />
|
|
51
77
|
</li>
|
|
52
78
|
);
|
|
53
79
|
}
|
|
@@ -55,9 +81,18 @@ function BreadcrumbsItem({
|
|
|
55
81
|
function HomeBreadcrumbItem() {
|
|
56
82
|
const homeHref = useBaseUrl('/');
|
|
57
83
|
return (
|
|
58
|
-
<
|
|
59
|
-
<
|
|
60
|
-
|
|
84
|
+
<li className="breadcrumbs__item">
|
|
85
|
+
<Link
|
|
86
|
+
aria-label={translate({
|
|
87
|
+
id: 'theme.docs.breadcrumbs.home',
|
|
88
|
+
message: 'Home page',
|
|
89
|
+
description: 'The ARIA label for the home page in the breadcrumbs',
|
|
90
|
+
})}
|
|
91
|
+
className={clsx('breadcrumbs__link', styles.breadcrumbsItemLink)}
|
|
92
|
+
href={homeHref}>
|
|
93
|
+
<IconHome className={styles.breadcrumbHomeIcon} />
|
|
94
|
+
</Link>
|
|
95
|
+
</li>
|
|
61
96
|
);
|
|
62
97
|
}
|
|
63
98
|
|
|
@@ -75,16 +110,30 @@ export default function DocBreadcrumbs(): JSX.Element | null {
|
|
|
75
110
|
ThemeClassNames.docs.docBreadcrumbs,
|
|
76
111
|
styles.breadcrumbsContainer,
|
|
77
112
|
)}
|
|
78
|
-
aria-label=
|
|
79
|
-
|
|
113
|
+
aria-label={translate({
|
|
114
|
+
id: 'theme.docs.breadcrumbs.navAriaLabel',
|
|
115
|
+
message: 'Breadcrumbs',
|
|
116
|
+
description: 'The ARIA label for the breadcrumbs',
|
|
117
|
+
})}>
|
|
118
|
+
<ul
|
|
119
|
+
className="breadcrumbs"
|
|
120
|
+
itemScope
|
|
121
|
+
itemType="https://schema.org/BreadcrumbList">
|
|
80
122
|
{homePageRoute && <HomeBreadcrumbItem />}
|
|
81
|
-
{breadcrumbs.map((item, idx) =>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
123
|
+
{breadcrumbs.map((item, idx) => {
|
|
124
|
+
const isLast = idx === breadcrumbs.length - 1;
|
|
125
|
+
return (
|
|
126
|
+
<BreadcrumbsItem
|
|
127
|
+
key={idx}
|
|
128
|
+
active={isLast}
|
|
129
|
+
index={idx}
|
|
130
|
+
addMicrodata={!!item.href}>
|
|
131
|
+
<BreadcrumbsItemLink href={item.href} isLast={isLast}>
|
|
132
|
+
{item.label}
|
|
133
|
+
</BreadcrumbsItemLink>
|
|
134
|
+
</BreadcrumbsItem>
|
|
135
|
+
);
|
|
136
|
+
})}
|
|
88
137
|
</ul>
|
|
89
138
|
</nav>
|
|
90
139
|
);
|
|
@@ -6,21 +6,14 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
.breadcrumbsContainer {
|
|
9
|
-
|
|
9
|
+
--ifm-breadcrumb-size-multiplier: 0.8;
|
|
10
|
+
margin-bottom: 0.8rem;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
html[data-theme='dark'] .breadcrumbsItemLink {
|
|
19
|
-
background-color: var(--ifm-color-gray-900);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@media (min-width: 997px) {
|
|
23
|
-
.breadcrumbsItemLink {
|
|
24
|
-
--ifm-breadcrumb-size-multiplier: 0.8;
|
|
25
|
-
}
|
|
13
|
+
.breadcrumbHomeIcon {
|
|
14
|
+
position: relative;
|
|
15
|
+
top: 1px;
|
|
16
|
+
vertical-align: top;
|
|
17
|
+
height: 1.1rem;
|
|
18
|
+
width: 1.1rem;
|
|
26
19
|
}
|