@docusaurus/theme-classic 2.0.0-beta.14 → 2.0.0-beta.15
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/lib/index.js +7 -16
- package/lib/theme-classic.d.ts +89 -182
- package/lib/validateThemeConfig.js +13 -1
- package/lib-next/theme/BackToTopButton/styles.module.css +1 -1
- package/lib-next/theme/BlogListPaginator/index.js +12 -12
- package/lib-next/theme/BlogPostAuthor/index.js +1 -1
- package/lib-next/theme/BlogPostAuthors/index.js +12 -2
- package/lib-next/theme/BlogPostAuthors/styles.module.css +10 -0
- package/lib-next/theme/BlogPostItem/index.js +12 -15
- package/lib-next/theme/BlogPostPage/index.js +10 -7
- package/lib-next/theme/BlogPostPaginator/index.js +11 -15
- package/lib-next/theme/BlogSidebar/styles.module.css +2 -0
- package/lib-next/theme/CodeBlock/index.js +44 -9
- package/lib-next/theme/CodeBlock/styles.module.css +12 -7
- package/lib-next/theme/DocCard/styles.module.css +3 -3
- package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +6 -3
- package/lib-next/theme/DocItem/index.js +9 -6
- package/lib-next/theme/DocItem/styles.module.css +2 -2
- package/lib-next/theme/DocPage/index.js +7 -3
- package/lib-next/theme/DocPage/styles.module.css +1 -0
- package/lib-next/theme/DocPaginator/index.js +26 -4
- package/lib-next/theme/DocSidebar/index.js +2 -2
- package/lib-next/theme/DocSidebar/styles.module.css +1 -0
- package/lib-next/theme/DocSidebarItem/index.js +43 -21
- package/lib-next/theme/DocSidebarItem/styles.module.css +1 -0
- package/lib-next/theme/DocSidebarItems/index.js +28 -0
- package/{src/theme/hooks/styles.css → lib-next/theme/DocSidebarItems/styles.module.css} +12 -2
- package/lib-next/theme/DocVersionBanner/index.js +4 -1
- package/lib-next/theme/Footer/styles.module.css +2 -1
- package/lib-next/theme/Heading/index.js +39 -42
- package/lib-next/theme/Heading/styles.css +1 -1
- package/lib-next/theme/Layout/index.js +1 -2
- package/lib-next/theme/LayoutHead/index.js +5 -9
- package/lib-next/theme/LayoutProviders/index.js +6 -6
- package/lib-next/theme/MDXComponents/index.js +18 -31
- package/lib-next/theme/MDXComponents/styles.css +4 -0
- package/lib-next/theme/MDXPage/index.js +3 -10
- package/lib-next/theme/Navbar/index.js +6 -6
- package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +4 -66
- package/lib-next/theme/NavbarItem/DocNavbarItem.js +5 -2
- package/lib-next/theme/NavbarItem/DocSidebarNavbarItem.js +73 -0
- package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +5 -3
- package/lib-next/theme/NavbarItem/DocsVersionNavbarItem.js +4 -1
- package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +5 -5
- package/lib-next/theme/NavbarItem/NavbarNavLink.js +70 -0
- package/lib-next/theme/NavbarItem/index.js +1 -2
- package/lib-next/theme/{hooks/styles.css → NavbarItem/utils.js} +3 -4
- package/lib-next/theme/PaginatorNavLink/index.js +20 -0
- package/lib-next/theme/SkipToContent/index.js +1 -1
- package/lib-next/theme/SkipToContent/styles.module.css +7 -0
- package/lib-next/theme/TOCCollapsible/styles.module.css +2 -2
- package/lib-next/theme/Tabs/__tests__/index.test.js +8 -6
- package/lib-next/theme/Tabs/index.js +6 -3
- package/lib-next/theme/Tag/styles.module.css +4 -4
- package/lib-next/theme/ThemedImage/index.js +2 -2
- package/lib-next/theme/Toggle/styles.module.css +16 -15
- package/lib-next/theme/prism-include-languages.js +10 -3
- package/package.json +16 -17
- package/src/index.ts +10 -21
- package/src/theme/Admonition/index.tsx +1 -1
- package/src/theme/BackToTopButton/styles.module.css +1 -1
- package/src/theme/BlogListPaginator/index.tsx +12 -12
- package/src/theme/BlogPostAuthor/index.tsx +1 -1
- package/src/theme/BlogPostAuthors/index.tsx +12 -2
- package/src/theme/BlogPostAuthors/styles.module.css +10 -0
- package/src/theme/BlogPostItem/index.tsx +13 -15
- package/src/theme/BlogPostPage/index.tsx +10 -7
- package/src/theme/BlogPostPaginator/index.tsx +11 -15
- package/src/theme/BlogSidebar/styles.module.css +2 -0
- package/src/theme/CodeBlock/index.tsx +45 -10
- package/src/theme/CodeBlock/styles.module.css +12 -7
- package/src/theme/DocCard/index.tsx +2 -2
- package/src/theme/DocCard/styles.module.css +3 -3
- package/src/theme/DocCardList/index.tsx +1 -1
- package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +7 -3
- package/src/theme/DocItem/index.tsx +9 -6
- package/src/theme/DocItem/styles.module.css +2 -2
- package/src/theme/DocItemFooter/index.tsx +1 -1
- package/src/theme/DocPage/index.tsx +8 -4
- package/src/theme/DocPage/styles.module.css +1 -0
- package/src/theme/DocPaginator/index.tsx +26 -4
- package/src/theme/DocSidebar/index.tsx +3 -3
- package/src/theme/DocSidebar/styles.module.css +1 -0
- package/src/theme/DocSidebarItem/index.tsx +34 -23
- package/src/theme/DocSidebarItem/styles.module.css +1 -0
- package/src/theme/DocSidebarItems/index.tsx +32 -0
- package/src/theme/{UserPreferencesContext.ts → DocSidebarItems/styles.module.css} +11 -3
- package/src/theme/DocVersionBanner/index.tsx +3 -3
- package/src/theme/Footer/index.tsx +4 -4
- package/src/theme/Footer/styles.module.css +2 -1
- package/src/theme/Heading/index.tsx +39 -46
- package/src/theme/Heading/styles.css +1 -1
- package/src/theme/Layout/index.tsx +1 -2
- package/src/theme/LayoutHead/index.tsx +4 -8
- package/src/theme/LayoutProviders/index.tsx +6 -6
- package/src/theme/MDXComponents/index.tsx +26 -37
- package/src/theme/MDXComponents/styles.css +4 -0
- package/src/theme/MDXPage/index.tsx +3 -11
- package/src/theme/Navbar/index.tsx +7 -7
- package/src/theme/NavbarItem/DefaultNavbarItem.tsx +6 -62
- package/src/theme/NavbarItem/DocNavbarItem.tsx +8 -5
- package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +84 -0
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +9 -6
- package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +2 -2
- package/src/theme/NavbarItem/DropdownNavbarItem.tsx +5 -5
- package/src/theme/NavbarItem/NavbarNavLink.tsx +68 -0
- package/src/theme/NavbarItem/index.tsx +3 -5
- package/{lib-next/theme/UserPreferencesContext.js → src/theme/NavbarItem/utils.ts} +4 -3
- package/src/theme/PaginatorNavLink/index.tsx +22 -0
- package/src/theme/SkipToContent/index.tsx +1 -1
- package/src/theme/SkipToContent/styles.module.css +7 -0
- package/src/theme/TOCCollapsible/styles.module.css +2 -2
- package/src/theme/TOCItems/index.tsx +2 -2
- package/src/theme/Tabs/index.tsx +7 -4
- package/src/theme/Tag/styles.module.css +4 -4
- package/src/theme/TagsListByLetter/index.tsx +1 -1
- package/src/theme/ThemedImage/index.tsx +2 -2
- package/src/theme/Toggle/index.tsx +1 -1
- package/src/theme/Toggle/styles.module.css +16 -15
- package/src/theme/prism-include-languages.ts +10 -3
- package/src/theme-classic.d.ts +89 -182
- package/src/translations.ts +2 -2
- package/src/validateThemeConfig.ts +16 -0
- package/lib-next/theme/DocPaginatorNavLink/index.js +0 -36
- package/lib-next/theme/ThemeContext.js +0 -9
- package/lib-next/theme/ThemeProvider/index.js +0 -28
- package/lib-next/theme/UserPreferencesProvider/index.js +0 -27
- package/lib-next/theme/hooks/useDocs.js +0 -10
- package/lib-next/theme/hooks/useHideableNavbar.js +0 -66
- package/lib-next/theme/hooks/useKeyboardNavigation.js +0 -35
- package/lib-next/theme/hooks/useLockBodyScroll.js +0 -18
- package/lib-next/theme/hooks/usePrismTheme.js +0 -20
- package/lib-next/theme/hooks/useTabGroupChoice.js +0 -39
- package/lib-next/theme/hooks/useTheme.js +0 -81
- package/lib-next/theme/hooks/useThemeContext.js +0 -22
- package/lib-next/theme/hooks/useUserPreferencesContext.js +0 -22
- package/lib-next/theme/hooks/useWindowSize.js +0 -59
- package/src/theme/DocPaginatorNavLink/index.tsx +0 -38
- package/src/theme/ThemeContext.ts +0 -15
- package/src/theme/ThemeProvider/index.tsx +0 -28
- package/src/theme/UserPreferencesProvider/index.tsx +0 -30
- package/src/theme/hooks/useDocs.ts +0 -11
- package/src/theme/hooks/useHideableNavbar.ts +0 -72
- package/src/theme/hooks/useKeyboardNavigation.ts +0 -39
- package/src/theme/hooks/useLockBodyScroll.ts +0 -20
- package/src/theme/hooks/usePrismTheme.ts +0 -22
- package/src/theme/hooks/useTabGroupChoice.ts +0 -46
- package/src/theme/hooks/useTheme.ts +0 -91
- package/src/theme/hooks/useThemeContext.ts +0 -23
- package/src/theme/hooks/useUserPreferencesContext.ts +0 -25
- package/src/theme/hooks/useWindowSize.ts +0 -69
|
@@ -11,6 +11,7 @@ import Translate, {translate} from '@docusaurus/Translate';
|
|
|
11
11
|
import Link from '@docusaurus/Link';
|
|
12
12
|
import {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
|
|
13
13
|
import {usePluralForm} from '@docusaurus/theme-common';
|
|
14
|
+
import {blogPostContainerID} from '@docusaurus/utils-common';
|
|
14
15
|
import MDXComponents from '@theme/MDXComponents';
|
|
15
16
|
import EditThisPage from '@theme/EditThisPage';
|
|
16
17
|
import styles from './styles.module.css';
|
|
@@ -62,10 +63,13 @@ function BlogPostItem(props) {
|
|
|
62
63
|
const image = assets.image ?? frontMatter.image;
|
|
63
64
|
const truncatedPost = !isBlogPostPage && truncated;
|
|
64
65
|
const tagsExists = tags.length > 0;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
const TitleHeading = isBlogPostPage ? 'h1' : 'h2';
|
|
67
|
+
return (
|
|
68
|
+
<article
|
|
69
|
+
className={!isBlogPostPage ? 'margin-bottom--xl' : undefined}
|
|
70
|
+
itemProp="blogPost"
|
|
71
|
+
itemScope
|
|
72
|
+
itemType="http://schema.org/BlogPosting">
|
|
69
73
|
<header>
|
|
70
74
|
<TitleHeading className={styles.blogPostTitle} itemProp="headline">
|
|
71
75
|
{isBlogPostPage ? (
|
|
@@ -90,16 +94,6 @@ function BlogPostItem(props) {
|
|
|
90
94
|
</div>
|
|
91
95
|
<BlogPostAuthors authors={authors} assets={assets} />
|
|
92
96
|
</header>
|
|
93
|
-
);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
return (
|
|
97
|
-
<article
|
|
98
|
-
className={!isBlogPostPage ? 'margin-bottom--xl' : undefined}
|
|
99
|
-
itemProp="blogPost"
|
|
100
|
-
itemScope
|
|
101
|
-
itemType="http://schema.org/BlogPosting">
|
|
102
|
-
{renderPostHeader()}
|
|
103
97
|
|
|
104
98
|
{image && (
|
|
105
99
|
<meta
|
|
@@ -110,7 +104,10 @@ function BlogPostItem(props) {
|
|
|
110
104
|
/>
|
|
111
105
|
)}
|
|
112
106
|
|
|
113
|
-
<div
|
|
107
|
+
<div // This ID is used for the feed generation to locate the main content
|
|
108
|
+
id={isBlogPostPage ? blogPostContainerID : undefined}
|
|
109
|
+
className="markdown"
|
|
110
|
+
itemProp="articleBody">
|
|
114
111
|
<MDXProvider components={MDXComponents}>{children}</MDXProvider>
|
|
115
112
|
</div>
|
|
116
113
|
|
|
@@ -14,14 +14,17 @@ import TOC from '@theme/TOC';
|
|
|
14
14
|
|
|
15
15
|
function BlogPostPage(props) {
|
|
16
16
|
const {content: BlogPostContents, sidebar} = props;
|
|
17
|
+
const {assets, metadata} = BlogPostContents;
|
|
17
18
|
const {
|
|
18
|
-
|
|
19
|
+
title,
|
|
20
|
+
description,
|
|
21
|
+
nextItem,
|
|
22
|
+
prevItem,
|
|
23
|
+
date,
|
|
24
|
+
tags,
|
|
25
|
+
authors,
|
|
19
26
|
frontMatter,
|
|
20
|
-
|
|
21
|
-
metadata,
|
|
22
|
-
} = BlogPostContents;
|
|
23
|
-
const {title, description, nextItem, prevItem, date, tags, authors} =
|
|
24
|
-
metadata;
|
|
27
|
+
} = metadata;
|
|
25
28
|
const {
|
|
26
29
|
hide_table_of_contents: hideTableOfContents,
|
|
27
30
|
keywords,
|
|
@@ -54,7 +57,7 @@ function BlogPostPage(props) {
|
|
|
54
57
|
<meta property="og:type" content="article" />
|
|
55
58
|
<meta property="article:published_time" content={date} />
|
|
56
59
|
|
|
57
|
-
{/* TODO double check those article
|
|
60
|
+
{/* TODO double check those article meta array syntaxes, see https://ogp.me/#array */}
|
|
58
61
|
{authors.some((author) => author.url) && (
|
|
59
62
|
<meta
|
|
60
63
|
property="article:author"
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import Translate, {translate} from '@docusaurus/Translate';
|
|
9
|
-
import
|
|
9
|
+
import PaginatorNavLink from '@theme/PaginatorNavLink';
|
|
10
10
|
|
|
11
11
|
function BlogPostPaginator(props) {
|
|
12
12
|
const {nextItem, prevItem} = props;
|
|
@@ -20,34 +20,30 @@ function BlogPostPaginator(props) {
|
|
|
20
20
|
})}>
|
|
21
21
|
<div className="pagination-nav__item">
|
|
22
22
|
{prevItem && (
|
|
23
|
-
<
|
|
24
|
-
|
|
23
|
+
<PaginatorNavLink
|
|
24
|
+
{...prevItem}
|
|
25
|
+
subLabel={
|
|
25
26
|
<Translate
|
|
26
27
|
id="theme.blog.post.paginator.newerPost"
|
|
27
28
|
description="The blog post button label to navigate to the newer/previous post">
|
|
28
29
|
Newer Post
|
|
29
30
|
</Translate>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
« {prevItem.title}
|
|
33
|
-
</div>
|
|
34
|
-
</Link>
|
|
31
|
+
}
|
|
32
|
+
/>
|
|
35
33
|
)}
|
|
36
34
|
</div>
|
|
37
35
|
<div className="pagination-nav__item pagination-nav__item--next">
|
|
38
36
|
{nextItem && (
|
|
39
|
-
<
|
|
40
|
-
|
|
37
|
+
<PaginatorNavLink
|
|
38
|
+
{...nextItem}
|
|
39
|
+
subLabel={
|
|
41
40
|
<Translate
|
|
42
41
|
id="theme.blog.post.paginator.olderPost"
|
|
43
42
|
description="The blog post button label to navigate to the older/next post">
|
|
44
43
|
Older Post
|
|
45
44
|
</Translate>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
{nextItem.title} »
|
|
49
|
-
</div>
|
|
50
|
-
</Link>
|
|
45
|
+
}
|
|
46
|
+
/>
|
|
51
47
|
)}
|
|
52
48
|
</div>
|
|
53
49
|
</nav>
|
|
@@ -4,7 +4,7 @@
|
|
|
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, {useEffect, useState} from 'react';
|
|
7
|
+
import React, {isValidElement, useEffect, useState} from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import Highlight, {defaultProps} from 'prism-react-renderer';
|
|
10
10
|
import copy from 'copy-text-to-clipboard';
|
|
@@ -15,14 +15,15 @@ import {
|
|
|
15
15
|
parseLanguage,
|
|
16
16
|
parseLines,
|
|
17
17
|
ThemeClassNames,
|
|
18
|
+
usePrismTheme,
|
|
18
19
|
} from '@docusaurus/theme-common';
|
|
19
|
-
import usePrismTheme from '@theme/hooks/usePrismTheme';
|
|
20
20
|
import styles from './styles.module.css';
|
|
21
21
|
export default function CodeBlock({
|
|
22
22
|
children,
|
|
23
|
-
className: blockClassName,
|
|
23
|
+
className: blockClassName = '',
|
|
24
24
|
metastring,
|
|
25
25
|
title,
|
|
26
|
+
language: languageProp,
|
|
26
27
|
}) {
|
|
27
28
|
const {prism} = useThemeConfig();
|
|
28
29
|
const [showCopied, setShowCopied] = useState(false);
|
|
@@ -36,15 +37,45 @@ export default function CodeBlock({
|
|
|
36
37
|
|
|
37
38
|
useEffect(() => {
|
|
38
39
|
setMounted(true);
|
|
39
|
-
}, []); //
|
|
40
|
-
//
|
|
41
|
-
//
|
|
40
|
+
}, []); // We still parse the metastring in case we want to support more syntax in the
|
|
41
|
+
// future. Note that MDX doesn't strip quotes when parsing metastring:
|
|
42
|
+
// "title=\"xyz\"" => title: "\"xyz\""
|
|
42
43
|
|
|
43
44
|
const codeBlockTitle = parseCodeBlockTitle(metastring) || title;
|
|
44
|
-
const prismTheme = usePrismTheme(); //
|
|
45
|
+
const prismTheme = usePrismTheme(); // <pre> tags in markdown map to CodeBlocks and they may contain JSX children.
|
|
46
|
+
// When the children is not a simple string, we just return a styled block without actually highlighting.
|
|
47
|
+
|
|
48
|
+
if (React.Children.toArray(children).some((el) => isValidElement(el))) {
|
|
49
|
+
return (
|
|
50
|
+
<Highlight
|
|
51
|
+
{...defaultProps}
|
|
52
|
+
key={String(mounted)}
|
|
53
|
+
theme={prismTheme}
|
|
54
|
+
code=""
|
|
55
|
+
language={'text'}>
|
|
56
|
+
{({className, style}) => (
|
|
57
|
+
<pre
|
|
58
|
+
/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
|
|
59
|
+
tabIndex={0}
|
|
60
|
+
className={clsx(
|
|
61
|
+
className,
|
|
62
|
+
styles.codeBlockStandalone,
|
|
63
|
+
'thin-scrollbar',
|
|
64
|
+
styles.codeBlockContainer,
|
|
65
|
+
blockClassName,
|
|
66
|
+
ThemeClassNames.common.codeBlock,
|
|
67
|
+
)}
|
|
68
|
+
style={style}>
|
|
69
|
+
<code className={styles.codeBlockLines}>{children}</code>
|
|
70
|
+
</pre>
|
|
71
|
+
)}
|
|
72
|
+
</Highlight>
|
|
73
|
+
);
|
|
74
|
+
} // The children is now guaranteed to be one/more plain strings
|
|
45
75
|
|
|
46
76
|
const content = Array.isArray(children) ? children.join('') : children;
|
|
47
|
-
const language =
|
|
77
|
+
const language =
|
|
78
|
+
languageProp ?? parseLanguage(blockClassName) ?? prism.defaultLanguage;
|
|
48
79
|
const {highlightLines, code} = parseLines(content, metastring, language);
|
|
49
80
|
|
|
50
81
|
const handleCopyCode = () => {
|
|
@@ -59,12 +90,16 @@ export default function CodeBlock({
|
|
|
59
90
|
key={String(mounted)}
|
|
60
91
|
theme={prismTheme}
|
|
61
92
|
code={code}
|
|
62
|
-
language={language}>
|
|
93
|
+
language={language ?? 'text'}>
|
|
63
94
|
{({className, style, tokens, getLineProps, getTokenProps}) => (
|
|
64
95
|
<div
|
|
65
96
|
className={clsx(
|
|
66
97
|
styles.codeBlockContainer,
|
|
67
98
|
blockClassName,
|
|
99
|
+
{
|
|
100
|
+
[`language-${language}`]:
|
|
101
|
+
language && !blockClassName.includes(`language-${language}`),
|
|
102
|
+
},
|
|
68
103
|
ThemeClassNames.common.codeBlock,
|
|
69
104
|
)}>
|
|
70
105
|
{codeBlockTitle && (
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
.codeBlockContent {
|
|
15
15
|
position: relative;
|
|
16
|
-
/*rtl:ignore*/
|
|
16
|
+
/* rtl:ignore */
|
|
17
17
|
direction: ltr;
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -26,19 +26,24 @@
|
|
|
26
26
|
border-top-right-radius: var(--ifm-global-radius);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
.codeBlock {
|
|
30
|
+
margin: 0;
|
|
31
|
+
padding: 0;
|
|
32
|
+
border-radius: var(--ifm-global-radius);
|
|
33
|
+
}
|
|
34
|
+
|
|
29
35
|
.codeBlockTitle + .codeBlockContent .codeBlock {
|
|
30
36
|
border-top-left-radius: 0;
|
|
31
37
|
border-top-right-radius: 0;
|
|
32
38
|
}
|
|
33
39
|
|
|
34
|
-
.
|
|
35
|
-
margin: 0;
|
|
40
|
+
.codeBlockStandalone {
|
|
36
41
|
padding: 0;
|
|
37
42
|
border-radius: var(--ifm-global-radius);
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
.copyButton {
|
|
41
|
-
background:
|
|
46
|
+
background: rgb(0 0 0 / 30%);
|
|
42
47
|
border-radius: var(--ifm-global-radius);
|
|
43
48
|
color: var(--ifm-color-white);
|
|
44
49
|
opacity: 0;
|
|
@@ -50,15 +55,15 @@
|
|
|
50
55
|
transition: opacity 200ms ease-in-out;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
|
-
.
|
|
58
|
+
.copyButton:focus,
|
|
54
59
|
.codeBlockContent:hover > .copyButton,
|
|
55
|
-
.
|
|
60
|
+
.codeBlockTitle:hover + .codeBlockContent .copyButton {
|
|
56
61
|
opacity: 1;
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
.codeBlockLines {
|
|
60
65
|
font: inherit;
|
|
61
|
-
/*rtl:ignore*/
|
|
66
|
+
/* rtl:ignore */
|
|
62
67
|
float: left;
|
|
63
68
|
min-width: 100%;
|
|
64
69
|
padding: var(--ifm-pre-padding);
|
|
@@ -7,14 +7,13 @@
|
|
|
7
7
|
|
|
8
8
|
.cardContainer {
|
|
9
9
|
height: 8rem;
|
|
10
|
-
|
|
11
10
|
color: var(--ifm-color-emphasis-800);
|
|
12
11
|
--ifm-link-color: var(--ifm-color-emphasis-800);
|
|
13
12
|
--ifm-link-hover-color: var(--ifm-color-emphasis-800);
|
|
14
13
|
--ifm-link-hover-decoration: none;
|
|
15
14
|
|
|
16
15
|
/* box-shadow: var(--ifm-global-shadow-lw); */
|
|
17
|
-
box-shadow: 0 1.5px 3px 0
|
|
16
|
+
box-shadow: 0 1.5px 3px 0 rgb(0 0 0 / 15%);
|
|
18
17
|
border: 1px solid var(--ifm-color-emphasis-200);
|
|
19
18
|
transition: box-shadow var(--ifm-transition-fast) ease,
|
|
20
19
|
background-color var(--ifm-transition-fast) ease;
|
|
@@ -22,8 +21,9 @@
|
|
|
22
21
|
|
|
23
22
|
.cardContainer.cardContainerLink:hover {
|
|
24
23
|
/* box-shadow: var(--ifm-global-shadow-md); */
|
|
25
|
-
box-shadow: 0 4px 8px 0
|
|
24
|
+
box-shadow: 0 4px 8px 0 rgb(0 0 0 / 20%);
|
|
26
25
|
}
|
|
26
|
+
|
|
27
27
|
html[data-theme='dark'] .cardContainer.cardContainerLink:hover {
|
|
28
28
|
--ifm-card-background-color: #2d2d2d; /* original, non-hovered color is #242526 */
|
|
29
29
|
}
|
|
@@ -11,7 +11,8 @@ import DocPaginator from '@theme/DocPaginator';
|
|
|
11
11
|
import Seo from '@theme/Seo';
|
|
12
12
|
import DocVersionBanner from '@theme/DocVersionBanner';
|
|
13
13
|
import DocVersionBadge from '@theme/DocVersionBadge';
|
|
14
|
-
import
|
|
14
|
+
import Heading from '@theme/Heading';
|
|
15
|
+
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
15
16
|
import styles from './styles.module.css';
|
|
16
17
|
export default function DocCategoryGeneratedIndexPage({
|
|
17
18
|
categoryGeneratedIndex,
|
|
@@ -22,14 +23,16 @@ export default function DocCategoryGeneratedIndexPage({
|
|
|
22
23
|
<Seo
|
|
23
24
|
title={categoryGeneratedIndex.title}
|
|
24
25
|
description={categoryGeneratedIndex.description}
|
|
26
|
+
keywords={categoryGeneratedIndex.keywords} // TODO `require` this?
|
|
27
|
+
image={useBaseUrl(categoryGeneratedIndex.image)}
|
|
25
28
|
/>
|
|
26
29
|
<div className={styles.generatedIndexPage}>
|
|
27
30
|
<DocVersionBanner />
|
|
28
31
|
<DocVersionBadge />
|
|
29
32
|
<header>
|
|
30
|
-
<
|
|
33
|
+
<Heading as="h1" className={styles.title}>
|
|
31
34
|
{categoryGeneratedIndex.title}
|
|
32
|
-
</
|
|
35
|
+
</Heading>
|
|
33
36
|
{categoryGeneratedIndex.description && (
|
|
34
37
|
<p>{categoryGeneratedIndex.description}</p>
|
|
35
38
|
)}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
|
-
import useWindowSize from '@theme/hooks/useWindowSize';
|
|
10
9
|
import DocPaginator from '@theme/DocPaginator';
|
|
11
10
|
import DocVersionBanner from '@theme/DocVersionBanner';
|
|
12
11
|
import DocVersionBadge from '@theme/DocVersionBadge';
|
|
@@ -14,9 +13,9 @@ import Seo from '@theme/Seo';
|
|
|
14
13
|
import DocItemFooter from '@theme/DocItemFooter';
|
|
15
14
|
import TOC from '@theme/TOC';
|
|
16
15
|
import TOCCollapsible from '@theme/TOCCollapsible';
|
|
17
|
-
import
|
|
16
|
+
import Heading from '@theme/Heading';
|
|
18
17
|
import styles from './styles.module.css';
|
|
19
|
-
import {ThemeClassNames} from '@docusaurus/theme-common';
|
|
18
|
+
import {ThemeClassNames, useWindowSize} from '@docusaurus/theme-common';
|
|
20
19
|
export default function DocItem(props) {
|
|
21
20
|
const {content: DocContent} = props;
|
|
22
21
|
const {metadata, frontMatter} = DocContent;
|
|
@@ -29,7 +28,7 @@ export default function DocItem(props) {
|
|
|
29
28
|
toc_max_heading_level: tocMaxHeadingLevel,
|
|
30
29
|
} = frontMatter;
|
|
31
30
|
const {description, title} = metadata; // We only add a title if:
|
|
32
|
-
// - user asks to hide it with
|
|
31
|
+
// - user asks to hide it with front matter
|
|
33
32
|
// - the markdown content does not already contain a top-level h1 heading
|
|
34
33
|
|
|
35
34
|
const shouldAddTitle =
|
|
@@ -75,11 +74,15 @@ export default function DocItem(props) {
|
|
|
75
74
|
<div
|
|
76
75
|
className={clsx(ThemeClassNames.docs.docMarkdown, 'markdown')}>
|
|
77
76
|
{/*
|
|
78
|
-
Title can be declared inside md content or declared through
|
|
77
|
+
Title can be declared inside md content or declared through front matter and added manually
|
|
79
78
|
To make both cases consistent, the added title is added under the same div.markdown block
|
|
80
79
|
See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
|
|
81
80
|
*/}
|
|
82
|
-
{shouldAddTitle &&
|
|
81
|
+
{shouldAddTitle && (
|
|
82
|
+
<header>
|
|
83
|
+
<Heading as="h1">{title}</Heading>
|
|
84
|
+
</header>
|
|
85
|
+
)}
|
|
83
86
|
|
|
84
87
|
<DocContent />
|
|
85
88
|
</div>
|
|
@@ -56,9 +56,13 @@ function DocPageContent({
|
|
|
56
56
|
|
|
57
57
|
{sidebar && (
|
|
58
58
|
<aside
|
|
59
|
-
className={clsx(
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
className={clsx(
|
|
60
|
+
ThemeClassNames.docs.docSidebarContainer,
|
|
61
|
+
styles.docSidebarContainer,
|
|
62
|
+
{
|
|
63
|
+
[styles.docSidebarContainerHidden]: hiddenSidebarContainer,
|
|
64
|
+
},
|
|
65
|
+
)}
|
|
62
66
|
onTransitionEnd={(e) => {
|
|
63
67
|
if (
|
|
64
68
|
!e.currentTarget.classList.contains(styles.docSidebarContainer)
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import {translate} from '@docusaurus/Translate';
|
|
9
|
-
import
|
|
8
|
+
import Translate, {translate} from '@docusaurus/Translate';
|
|
9
|
+
import PaginatorNavLink from '@theme/PaginatorNavLink';
|
|
10
10
|
|
|
11
11
|
function DocPaginator(props) {
|
|
12
12
|
const {previous, next} = props;
|
|
@@ -19,10 +19,32 @@ function DocPaginator(props) {
|
|
|
19
19
|
description: 'The ARIA label for the docs pagination',
|
|
20
20
|
})}>
|
|
21
21
|
<div className="pagination-nav__item">
|
|
22
|
-
{previous &&
|
|
22
|
+
{previous && (
|
|
23
|
+
<PaginatorNavLink
|
|
24
|
+
{...previous}
|
|
25
|
+
subLabel={
|
|
26
|
+
<Translate
|
|
27
|
+
id="theme.docs.paginator.previous"
|
|
28
|
+
description="The label used to navigate to the previous doc">
|
|
29
|
+
Previous
|
|
30
|
+
</Translate>
|
|
31
|
+
}
|
|
32
|
+
/>
|
|
33
|
+
)}
|
|
23
34
|
</div>
|
|
24
35
|
<div className="pagination-nav__item pagination-nav__item--next">
|
|
25
|
-
{next &&
|
|
36
|
+
{next && (
|
|
37
|
+
<PaginatorNavLink
|
|
38
|
+
{...next}
|
|
39
|
+
subLabel={
|
|
40
|
+
<Translate
|
|
41
|
+
id="theme.docs.paginator.next"
|
|
42
|
+
description="The label used to navigate to the next doc">
|
|
43
|
+
Next
|
|
44
|
+
</Translate>
|
|
45
|
+
}
|
|
46
|
+
/>
|
|
47
|
+
)}
|
|
26
48
|
</div>
|
|
27
49
|
</nav>
|
|
28
50
|
);
|
|
@@ -12,12 +12,12 @@ import {
|
|
|
12
12
|
MobileSecondaryMenuFiller,
|
|
13
13
|
ThemeClassNames,
|
|
14
14
|
useScrollPosition,
|
|
15
|
+
useWindowSize,
|
|
15
16
|
} from '@docusaurus/theme-common';
|
|
16
|
-
import useWindowSize from '@theme/hooks/useWindowSize';
|
|
17
17
|
import Logo from '@theme/Logo';
|
|
18
18
|
import IconArrow from '@theme/IconArrow';
|
|
19
19
|
import {translate} from '@docusaurus/Translate';
|
|
20
|
-
import
|
|
20
|
+
import DocSidebarItems from '@theme/DocSidebarItems';
|
|
21
21
|
import styles from './styles.module.css';
|
|
22
22
|
|
|
23
23
|
function useShowAnnouncementBar() {
|
|
@@ -4,7 +4,7 @@
|
|
|
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, {useEffect,
|
|
7
|
+
import React, {useEffect, useMemo} from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import {
|
|
10
10
|
isActiveSidebarItem,
|
|
@@ -13,27 +13,16 @@ import {
|
|
|
13
13
|
useCollapsible,
|
|
14
14
|
findFirstCategoryLink,
|
|
15
15
|
ThemeClassNames,
|
|
16
|
+
useThemeConfig,
|
|
17
|
+
useDocSidebarItemsExpandedState,
|
|
16
18
|
} from '@docusaurus/theme-common';
|
|
17
19
|
import Link from '@docusaurus/Link';
|
|
18
20
|
import isInternalUrl from '@docusaurus/isInternalUrl';
|
|
19
21
|
import {translate} from '@docusaurus/Translate';
|
|
20
22
|
import IconExternalLink from '@theme/IconExternalLink';
|
|
23
|
+
import DocSidebarItems from '@theme/DocSidebarItems';
|
|
21
24
|
import styles from './styles.module.css';
|
|
22
|
-
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
23
|
-
// TODO this item should probably not receive the "activePath" props
|
|
24
|
-
// TODO this triggers whole sidebar re-renders on navigation
|
|
25
|
-
|
|
26
|
-
export const DocSidebarItems = memo(({items, ...props}) => (
|
|
27
|
-
<>
|
|
28
|
-
{items.map((item, index) => (
|
|
29
|
-
<DocSidebarItem
|
|
30
|
-
key={index} // sidebar is static, the index does not change
|
|
31
|
-
item={item}
|
|
32
|
-
{...props}
|
|
33
|
-
/>
|
|
34
|
-
))}
|
|
35
|
-
</>
|
|
36
|
-
));
|
|
25
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
37
26
|
export default function DocSidebarItem({item, ...props}) {
|
|
38
27
|
switch (item.type) {
|
|
39
28
|
case 'category':
|
|
@@ -85,12 +74,13 @@ function DocSidebarItemCategory({
|
|
|
85
74
|
onItemClick,
|
|
86
75
|
activePath,
|
|
87
76
|
level,
|
|
77
|
+
index,
|
|
88
78
|
...props
|
|
89
79
|
}) {
|
|
90
80
|
const {items, label, collapsible, className, href} = item;
|
|
91
81
|
const hrefWithSSRFallback = useCategoryHrefWithSSRFallback(item);
|
|
92
82
|
const isActive = isActiveSidebarItem(item, activePath);
|
|
93
|
-
const {collapsed, setCollapsed
|
|
83
|
+
const {collapsed, setCollapsed} = useCollapsible({
|
|
94
84
|
// active categories are always initialized as expanded
|
|
95
85
|
// the default (item.collapsed) is only used for non-active categories
|
|
96
86
|
initialState: () => {
|
|
@@ -106,6 +96,30 @@ function DocSidebarItemCategory({
|
|
|
106
96
|
collapsed,
|
|
107
97
|
setCollapsed,
|
|
108
98
|
});
|
|
99
|
+
const {expandedItem, setExpandedItem} = useDocSidebarItemsExpandedState();
|
|
100
|
+
|
|
101
|
+
function updateCollapsed(toCollapsed = !collapsed) {
|
|
102
|
+
setExpandedItem(toCollapsed ? null : index);
|
|
103
|
+
setCollapsed(toCollapsed);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const {autoCollapseSidebarCategories} = useThemeConfig();
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
if (
|
|
109
|
+
collapsible &&
|
|
110
|
+
expandedItem &&
|
|
111
|
+
expandedItem !== index &&
|
|
112
|
+
autoCollapseSidebarCategories
|
|
113
|
+
) {
|
|
114
|
+
setCollapsed(true);
|
|
115
|
+
}
|
|
116
|
+
}, [
|
|
117
|
+
collapsible,
|
|
118
|
+
expandedItem,
|
|
119
|
+
index,
|
|
120
|
+
setCollapsed,
|
|
121
|
+
autoCollapseSidebarCategories,
|
|
122
|
+
]);
|
|
109
123
|
return (
|
|
110
124
|
<li
|
|
111
125
|
className={clsx(
|
|
@@ -131,16 +145,17 @@ function DocSidebarItemCategory({
|
|
|
131
145
|
onItemClick?.(item);
|
|
132
146
|
|
|
133
147
|
if (href) {
|
|
134
|
-
|
|
148
|
+
updateCollapsed(false);
|
|
135
149
|
} else {
|
|
136
150
|
e.preventDefault();
|
|
137
|
-
|
|
151
|
+
updateCollapsed();
|
|
138
152
|
}
|
|
139
153
|
}
|
|
140
154
|
: () => {
|
|
141
155
|
onItemClick?.(item);
|
|
142
156
|
}
|
|
143
157
|
}
|
|
158
|
+
aria-current={isActive ? 'page' : undefined}
|
|
144
159
|
href={collapsible ? hrefWithSSRFallback ?? '#' : hrefWithSSRFallback}
|
|
145
160
|
{...props}>
|
|
146
161
|
{label}
|
|
@@ -162,7 +177,7 @@ function DocSidebarItemCategory({
|
|
|
162
177
|
className="clean-btn menu__caret"
|
|
163
178
|
onClick={(e) => {
|
|
164
179
|
e.preventDefault();
|
|
165
|
-
|
|
180
|
+
updateCollapsed();
|
|
166
181
|
}}
|
|
167
182
|
/>
|
|
168
183
|
)}
|
|
@@ -181,7 +196,14 @@ function DocSidebarItemCategory({
|
|
|
181
196
|
);
|
|
182
197
|
}
|
|
183
198
|
|
|
184
|
-
function DocSidebarItemLink({
|
|
199
|
+
function DocSidebarItemLink({
|
|
200
|
+
item,
|
|
201
|
+
onItemClick,
|
|
202
|
+
activePath,
|
|
203
|
+
level,
|
|
204
|
+
index,
|
|
205
|
+
...props
|
|
206
|
+
}) {
|
|
185
207
|
const {href, label, className} = item;
|
|
186
208
|
const isActive = isActiveSidebarItem(item, activePath);
|
|
187
209
|
return (
|