@docusaurus/theme-classic 2.0.0-beta.15 → 2.0.0-beta.16
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/getSwizzleConfig.js +102 -0
- package/lib/index.js +14 -11
- package/lib/theme-classic.d.ts +123 -97
- package/lib/translations.js +29 -32
- package/lib/validateThemeConfig.js +7 -4
- package/lib-next/theme/AnnouncementBar/index.js +1 -4
- package/lib-next/theme/BackToTopButton/index.js +6 -6
- package/lib-next/theme/BackToTopButton/styles.module.css +3 -1
- package/lib-next/theme/BlogLayout/index.js +1 -4
- package/lib-next/theme/BlogListPage/index.js +1 -4
- package/lib-next/theme/BlogListPaginator/index.js +1 -4
- package/lib-next/theme/BlogPostAuthor/index.js +18 -24
- package/lib-next/theme/BlogPostItem/index.js +12 -4
- package/lib-next/theme/BlogPostPage/index.js +4 -6
- package/lib-next/theme/BlogPostPaginator/index.js +1 -4
- package/lib-next/theme/BlogTagsListPage/index.js +1 -4
- package/lib-next/theme/BlogTagsPostsPage/index.js +4 -2
- package/lib-next/theme/CodeBlock/index.js +2 -1
- package/lib-next/theme/Details/index.js +2 -1
- package/lib-next/theme/DocBreadcrumbs/index.js +76 -0
- package/lib-next/theme/DocBreadcrumbs/styles.module.css +26 -0
- package/lib-next/theme/DocCard/index.js +12 -1
- package/lib-next/theme/DocCard/styles.module.css +1 -1
- package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +2 -0
- package/lib-next/theme/DocItem/index.js +8 -5
- package/lib-next/theme/DocPage/index.js +2 -4
- package/lib-next/theme/DocPage/styles.module.css +3 -3
- package/lib-next/theme/DocPaginator/index.js +1 -4
- package/lib-next/theme/DocSidebar/styles.module.css +4 -4
- package/lib-next/theme/DocSidebarItem/index.js +39 -14
- package/lib-next/theme/DocSidebarItem/styles.module.css +3 -10
- package/lib-next/theme/DocTagsListPage/index.js +1 -4
- package/lib-next/theme/DocVersionBadge/index.js +8 -1
- package/lib-next/theme/Footer/index.js +8 -4
- package/lib-next/theme/Heading/index.js +0 -1
- package/lib-next/theme/Heading/styles.module.css +16 -0
- package/lib-next/theme/IconArrow/index.js +1 -4
- package/lib-next/theme/IconEdit/index.js +1 -4
- package/lib-next/theme/IconExternalLink/index.js +1 -4
- package/lib-next/theme/IconLanguage/index.js +1 -4
- package/lib-next/theme/IconMenu/index.js +6 -4
- package/lib-next/theme/Layout/index.js +1 -4
- package/lib-next/theme/LayoutHead/index.js +4 -0
- package/lib-next/theme/Logo/index.js +1 -4
- package/lib-next/theme/MDXComponents/index.js +4 -3
- package/lib-next/theme/MDXPage/index.js +1 -4
- package/lib-next/theme/Navbar/index.js +1 -3
- package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +1 -3
- package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +2 -2
- package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +1 -3
- package/lib-next/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +8 -1
- package/lib-next/theme/NavbarItem/index.js +2 -2
- package/lib-next/theme/NotFound.js +1 -4
- package/lib-next/theme/PaginatorNavLink/index.js +1 -4
- package/lib-next/theme/SearchBar.js +1 -1
- package/lib-next/theme/SearchMetadata/index.js +11 -6
- package/lib-next/theme/SkipToContent/index.js +1 -3
- package/lib-next/theme/TOC/index.js +2 -5
- package/lib-next/theme/TOCInline/index.js +1 -4
- package/lib-next/theme/TOCItems/index.js +3 -3
- package/lib-next/theme/TabItem/index.js +1 -4
- package/lib-next/theme/Tabs/__tests__/index.test.js +3 -1
- package/lib-next/theme/Tabs/index.js +1 -1
- package/lib-next/theme/Tag/index.js +1 -4
- package/lib-next/theme/TagsListByLetter/index.js +1 -3
- package/lib-next/theme/ThemedImage/index.js +1 -4
- package/lib-next/theme/ThemedImage/styles.module.css +2 -2
- package/lib-next/theme/Toggle/index.js +25 -2
- package/lib-next/theme/prism-include-languages.js +17 -23
- package/package.json +21 -22
- package/src/getSwizzleConfig.ts +101 -0
- package/src/index.ts +7 -21
- package/src/theme/AnnouncementBar/index.tsx +1 -3
- package/src/theme/BackToTopButton/index.tsx +8 -7
- package/src/theme/BackToTopButton/styles.module.css +3 -1
- package/src/theme/BlogLayout/index.tsx +1 -3
- package/src/theme/BlogListPage/index.tsx +1 -3
- package/src/theme/BlogListPaginator/index.tsx +1 -3
- package/src/theme/BlogPostAuthor/index.tsx +18 -23
- package/src/theme/BlogPostItem/index.tsx +10 -4
- package/src/theme/BlogPostPage/index.tsx +4 -5
- package/src/theme/BlogPostPaginator/index.tsx +1 -3
- package/src/theme/BlogTagsListPage/index.tsx +1 -3
- package/src/theme/BlogTagsPostsPage/index.tsx +3 -1
- package/src/theme/CodeBlock/index.tsx +2 -1
- package/src/theme/Details/index.tsx +2 -1
- package/src/theme/DocBreadcrumbs/index.tsx +91 -0
- package/src/theme/DocBreadcrumbs/styles.module.css +26 -0
- package/src/theme/DocCard/index.tsx +10 -1
- package/src/theme/DocCard/styles.module.css +1 -1
- package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +2 -0
- package/src/theme/DocItem/index.tsx +7 -4
- package/src/theme/DocPage/index.tsx +2 -4
- package/src/theme/DocPage/styles.module.css +3 -3
- package/src/theme/DocPaginator/index.tsx +1 -3
- package/src/theme/DocSidebar/styles.module.css +4 -4
- package/src/theme/DocSidebarItem/index.tsx +43 -13
- package/src/theme/DocSidebarItem/styles.module.css +3 -10
- package/src/theme/DocTagsListPage/index.tsx +1 -3
- package/src/theme/DocVersionBadge/index.tsx +6 -1
- package/src/theme/Footer/index.tsx +8 -4
- package/src/theme/Heading/index.tsx +0 -1
- package/src/theme/Heading/styles.module.css +16 -0
- package/src/theme/IconArrow/index.tsx +1 -3
- package/src/theme/IconEdit/index.tsx +4 -3
- package/src/theme/IconExternalLink/index.tsx +4 -3
- package/src/theme/IconLanguage/index.tsx +5 -3
- package/src/theme/IconMenu/index.tsx +1 -3
- package/src/theme/Layout/index.tsx +1 -3
- package/src/theme/LayoutHead/index.tsx +4 -0
- package/src/theme/Logo/index.tsx +1 -3
- package/src/theme/MDXComponents/index.tsx +4 -3
- package/src/theme/MDXPage/index.tsx +1 -3
- package/src/theme/Navbar/index.tsx +1 -3
- package/src/theme/NavbarItem/DefaultNavbarItem.tsx +1 -3
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +2 -2
- package/src/theme/NavbarItem/DropdownNavbarItem.tsx +4 -3
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +8 -1
- package/src/theme/NavbarItem/index.tsx +2 -2
- package/src/theme/NotFound.tsx +1 -3
- package/src/theme/PaginatorNavLink/index.tsx +1 -3
- package/src/theme/SearchBar.tsx +2 -1
- package/src/theme/SearchMetadata/index.tsx +12 -6
- package/src/theme/SkipToContent/index.tsx +1 -3
- package/src/theme/TOC/index.tsx +3 -5
- package/src/theme/TOCCollapsible/index.tsx +2 -2
- package/src/theme/TOCInline/index.tsx +3 -5
- package/src/theme/TOCItems/index.tsx +11 -7
- package/src/theme/TabItem/index.tsx +5 -3
- package/src/theme/Tabs/index.tsx +1 -1
- package/src/theme/Tag/index.tsx +1 -3
- package/src/theme/TagsListByLetter/index.tsx +1 -3
- package/src/theme/ThemedImage/index.tsx +1 -3
- package/src/theme/ThemedImage/styles.module.css +2 -2
- package/src/theme/Toggle/index.tsx +26 -2
- package/src/theme/prism-include-languages.ts +20 -23
- package/src/theme-classic.d.ts +123 -97
- package/src/translations.ts +41 -39
- package/src/validateThemeConfig.ts +10 -8
- package/lib-next/theme/DocSidebarItems/styles.module.css +0 -20
- package/lib-next/theme/Heading/styles.css +0 -22
- package/src/theme/DocSidebarItems/styles.module.css +0 -20
- package/src/theme/Heading/styles.css +0 -22
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
// By default, the classic theme does not provide any SearchBar implementation
|
|
8
|
-
// If you swizzled this
|
|
8
|
+
// If you swizzled this, it is your responsibility to provide an implementation
|
|
9
9
|
// Tip: swizzle the SearchBar from the Algolia theme for inspiration:
|
|
10
10
|
// npm run swizzle @docusaurus/theme-search-algolia SearchBar
|
|
11
11
|
export {default} from '@docusaurus/Noop';
|
|
@@ -6,15 +6,20 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import Head from '@docusaurus/Head';
|
|
9
|
-
// Note: we
|
|
10
|
-
//
|
|
11
|
-
//
|
|
9
|
+
// Note: we bias toward using Algolia metadata on purpose
|
|
10
|
+
// Not doing so leads to confusion in the community,
|
|
11
|
+
// as it requires to first crawl the site with the Algolia plugin enabled first
|
|
12
|
+
// - https://github.com/facebook/docusaurus/issues/6693
|
|
13
|
+
// - https://github.com/facebook/docusaurus/issues/4555
|
|
12
14
|
export default function SearchMetadata({locale, version, tag}) {
|
|
15
|
+
// Seems safe to consider here the locale is the language, as the existing
|
|
16
|
+
// docsearch:language filter is afaik a regular string-based filter
|
|
17
|
+
const language = locale;
|
|
13
18
|
return (
|
|
14
19
|
<Head>
|
|
15
|
-
{
|
|
16
|
-
{version && <meta name="
|
|
17
|
-
{tag && <meta name="docusaurus_tag" content={tag} />}
|
|
20
|
+
{language && <meta name="docsearch:language" content={language} />}
|
|
21
|
+
{version && <meta name="docsearch:version" content={version} />}
|
|
22
|
+
{tag && <meta name="docsearch:docusaurus_tag" content={tag} />}
|
|
18
23
|
</Head>
|
|
19
24
|
);
|
|
20
25
|
}
|
|
@@ -16,7 +16,7 @@ function programmaticFocus(el) {
|
|
|
16
16
|
el.removeAttribute('tabindex');
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function SkipToContent() {
|
|
19
|
+
export default function SkipToContent() {
|
|
20
20
|
const containerRef = useRef(null);
|
|
21
21
|
const {action} = useHistory();
|
|
22
22
|
|
|
@@ -49,5 +49,3 @@ function SkipToContent() {
|
|
|
49
49
|
</div>
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
export default SkipToContent;
|
|
@@ -8,12 +8,11 @@ import React from 'react';
|
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import TOCItems from '@theme/TOCItems';
|
|
10
10
|
import styles from './styles.module.css'; // Using a custom className
|
|
11
|
-
// This prevents
|
|
11
|
+
// This prevents TOCInline/TOCCollapsible getting highlighted by mistake
|
|
12
12
|
|
|
13
13
|
const LINK_CLASS_NAME = 'table-of-contents__link toc-highlight';
|
|
14
14
|
const LINK_ACTIVE_CLASS_NAME = 'table-of-contents__link--active';
|
|
15
|
-
|
|
16
|
-
function TOC({className, ...props}) {
|
|
15
|
+
export default function TOC({className, ...props}) {
|
|
17
16
|
return (
|
|
18
17
|
<div className={clsx(styles.tableOfContents, 'thin-scrollbar', className)}>
|
|
19
18
|
<TOCItems
|
|
@@ -24,5 +23,3 @@ function TOC({className, ...props}) {
|
|
|
24
23
|
</div>
|
|
25
24
|
);
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
export default TOC;
|
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import styles from './styles.module.css';
|
|
9
9
|
import TOCItems from '@theme/TOCItems';
|
|
10
|
-
|
|
11
|
-
function TOCInline({toc, minHeadingLevel, maxHeadingLevel}) {
|
|
10
|
+
export default function TOCInline({toc, minHeadingLevel, maxHeadingLevel}) {
|
|
12
11
|
return (
|
|
13
12
|
<div className={styles.tableOfContentsInline}>
|
|
14
13
|
<TOCItems
|
|
@@ -21,5 +20,3 @@ function TOCInline({toc, minHeadingLevel, maxHeadingLevel}) {
|
|
|
21
20
|
</div>
|
|
22
21
|
);
|
|
23
22
|
}
|
|
24
|
-
|
|
25
|
-
export default TOCInline;
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
import React, {useMemo} from 'react';
|
|
8
8
|
import {
|
|
9
9
|
useThemeConfig,
|
|
10
|
-
useTOCFilter,
|
|
11
10
|
useTOCHighlight,
|
|
11
|
+
useFilteredAndTreeifiedTOC,
|
|
12
12
|
} from '@docusaurus/theme-common'; // Recursive component rendering the toc tree
|
|
13
13
|
|
|
14
14
|
/* eslint-disable jsx-a11y/control-has-associated-label */
|
|
@@ -56,7 +56,7 @@ export default function TOCItems({
|
|
|
56
56
|
minHeadingLevelOption ?? themeConfig.tableOfContents.minHeadingLevel;
|
|
57
57
|
const maxHeadingLevel =
|
|
58
58
|
maxHeadingLevelOption ?? themeConfig.tableOfContents.maxHeadingLevel;
|
|
59
|
-
const
|
|
59
|
+
const tocTree = useFilteredAndTreeifiedTOC({
|
|
60
60
|
toc,
|
|
61
61
|
minHeadingLevel,
|
|
62
62
|
maxHeadingLevel,
|
|
@@ -76,7 +76,7 @@ export default function TOCItems({
|
|
|
76
76
|
useTOCHighlight(tocHighlightConfig);
|
|
77
77
|
return (
|
|
78
78
|
<TOCItemList
|
|
79
|
-
toc={
|
|
79
|
+
toc={tocTree}
|
|
80
80
|
className={className}
|
|
81
81
|
linkClassName={linkClassName}
|
|
82
82
|
{...props}
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
|
|
9
|
-
function TabItem({children, hidden, className}) {
|
|
8
|
+
export default function TabItem({children, hidden, className}) {
|
|
10
9
|
return (
|
|
11
10
|
<div
|
|
12
11
|
role="tabpanel"
|
|
@@ -18,5 +17,3 @@ function TabItem({children, hidden, className}) {
|
|
|
18
17
|
</div>
|
|
19
18
|
);
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
export default TabItem;
|
|
@@ -42,7 +42,7 @@ function TabsComponent(props) {
|
|
|
42
42
|
);
|
|
43
43
|
});
|
|
44
44
|
const values =
|
|
45
|
-
valuesProp ?? //
|
|
45
|
+
valuesProp ?? // Only pick keys that we recognize. MDX would inject some keys by default
|
|
46
46
|
children.map(({props: {value, label, attributes}}) => ({
|
|
47
47
|
value,
|
|
48
48
|
label,
|
|
@@ -8,8 +8,7 @@ import React from 'react';
|
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import Link from '@docusaurus/Link';
|
|
10
10
|
import styles from './styles.module.css';
|
|
11
|
-
|
|
12
|
-
function Tag(props) {
|
|
11
|
+
export default function Tag(props) {
|
|
13
12
|
const {permalink, name, count} = props;
|
|
14
13
|
return (
|
|
15
14
|
<Link
|
|
@@ -23,5 +22,3 @@ function Tag(props) {
|
|
|
23
22
|
</Link>
|
|
24
23
|
);
|
|
25
24
|
}
|
|
26
|
-
|
|
27
|
-
export default Tag;
|
|
@@ -25,7 +25,7 @@ function TagLetterEntryItem({letterEntry}) {
|
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function TagsListByLetter({tags}) {
|
|
28
|
+
export default function TagsListByLetter({tags}) {
|
|
29
29
|
const letterList = listTagsByLetters(tags);
|
|
30
30
|
return (
|
|
31
31
|
<section className="margin-vert--lg">
|
|
@@ -38,5 +38,3 @@ function TagsListByLetter({tags}) {
|
|
|
38
38
|
</section>
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
export default TagsListByLetter;
|
|
@@ -9,8 +9,7 @@ import clsx from 'clsx';
|
|
|
9
9
|
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
10
10
|
import {useColorMode} from '@docusaurus/theme-common';
|
|
11
11
|
import styles from './styles.module.css';
|
|
12
|
-
|
|
13
|
-
function ThemedImage(props) {
|
|
12
|
+
export default function ThemedImage(props) {
|
|
14
13
|
const isBrowser = useIsBrowser();
|
|
15
14
|
const {isDarkTheme} = useColorMode();
|
|
16
15
|
const {sources, className, alt = '', ...propsRest} = props;
|
|
@@ -37,5 +36,3 @@ function ThemedImage(props) {
|
|
|
37
36
|
</>
|
|
38
37
|
);
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
export default ThemedImage;
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
display: none;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
[data-theme='light'] .themedImage--light {
|
|
13
13
|
display: initial;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
[data-theme='dark'] .themedImage--dark {
|
|
17
17
|
display: initial;
|
|
18
18
|
}
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, {useState, useRef, memo} from 'react';
|
|
7
|
+
import React, {useState, useRef, useEffect, memo} from 'react';
|
|
8
8
|
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
9
9
|
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
10
|
+
import {translate} from '@docusaurus/Translate';
|
|
10
11
|
import clsx from 'clsx';
|
|
11
12
|
import styles from './styles.module.css'; // Based on react-toggle (https://github.com/aaronshaf/react-toggle/).
|
|
12
13
|
|
|
@@ -16,6 +17,9 @@ const ToggleComponent = memo(
|
|
|
16
17
|
const [checked, setChecked] = useState(defaultChecked);
|
|
17
18
|
const [focused, setFocused] = useState(false);
|
|
18
19
|
const inputRef = useRef(null);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
setChecked(defaultChecked);
|
|
22
|
+
}, [defaultChecked]);
|
|
19
23
|
return (
|
|
20
24
|
<div
|
|
21
25
|
className={clsx(styles.toggle, className, {
|
|
@@ -47,7 +51,26 @@ const ToggleComponent = memo(
|
|
|
47
51
|
checked={checked}
|
|
48
52
|
type="checkbox"
|
|
49
53
|
className={styles.toggleScreenReader}
|
|
50
|
-
aria-label=
|
|
54
|
+
aria-label={translate(
|
|
55
|
+
{
|
|
56
|
+
message: 'Switch between dark and light mode (currently {mode})',
|
|
57
|
+
id: 'theme.colorToggle.ariaLabel',
|
|
58
|
+
description: 'The ARIA label for the navbar color mode toggle',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
mode: checked
|
|
62
|
+
? translate({
|
|
63
|
+
message: 'dark mode',
|
|
64
|
+
id: 'theme.colorToggle.ariaLabel.mode.dark',
|
|
65
|
+
description: 'The name for the dark color mode',
|
|
66
|
+
})
|
|
67
|
+
: translate({
|
|
68
|
+
message: 'light mode',
|
|
69
|
+
id: 'theme.colorToggle.ariaLabel.mode.light',
|
|
70
|
+
description: 'The name for the light color mode',
|
|
71
|
+
}),
|
|
72
|
+
},
|
|
73
|
+
)}
|
|
51
74
|
onChange={onChange}
|
|
52
75
|
onClick={() => setChecked(!checked)}
|
|
53
76
|
onFocus={() => setFocused(true)}
|
|
@@ -4,28 +4,22 @@
|
|
|
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 ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
8
7
|
import siteConfig from '@generated/docusaurus.config';
|
|
8
|
+
export default function prismIncludeLanguages(PrismObject) {
|
|
9
|
+
const {
|
|
10
|
+
themeConfig: {prism},
|
|
11
|
+
} = siteConfig;
|
|
12
|
+
const {additionalLanguages} = prism; // Prism components work on the Prism instance on the window, while prism-
|
|
13
|
+
// react-renderer uses its own Prism instance. We temporarily mount the
|
|
14
|
+
// instance onto window, import components to enhance it, then remove it to
|
|
15
|
+
// avoid polluting global namespace.
|
|
16
|
+
// You can mutate PrismObject: registering plugins, deleting languages... As
|
|
17
|
+
// long as you don't re-assign it
|
|
9
18
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// the instance onto window, import components to enhance it, then remove it
|
|
18
|
-
// to avoid polluting global namespace.
|
|
19
|
-
// You can mutate this object: registering plugins, deleting languages... As
|
|
20
|
-
// long as you don't re-assign it
|
|
21
|
-
|
|
22
|
-
window.Prism = PrismObject;
|
|
23
|
-
additionalLanguages.forEach((lang) => {
|
|
24
|
-
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
25
|
-
require(`prismjs/components/prism-${lang}`);
|
|
26
|
-
});
|
|
27
|
-
delete window.Prism;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export default prismIncludeLanguages;
|
|
19
|
+
globalThis.Prism = PrismObject;
|
|
20
|
+
additionalLanguages.forEach((lang) => {
|
|
21
|
+
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
22
|
+
require(`prismjs/components/prism-${lang}`);
|
|
23
|
+
});
|
|
24
|
+
delete globalThis.Prism;
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.16",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -21,35 +21,34 @@
|
|
|
21
21
|
"format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@docusaurus/core": "2.0.0-beta.
|
|
25
|
-
"@docusaurus/plugin-content-blog": "2.0.0-beta.
|
|
26
|
-
"@docusaurus/plugin-content-docs": "2.0.0-beta.
|
|
27
|
-
"@docusaurus/plugin-content-pages": "2.0.0-beta.
|
|
28
|
-
"@docusaurus/theme-common": "2.0.0-beta.
|
|
29
|
-
"@docusaurus/theme-translations": "2.0.0-beta.
|
|
30
|
-
"@docusaurus/utils": "2.0.0-beta.
|
|
31
|
-
"@docusaurus/utils-common": "2.0.0-beta.
|
|
32
|
-
"@docusaurus/utils-validation": "2.0.0-beta.
|
|
33
|
-
"@mdx-js/react": "^1.6.
|
|
24
|
+
"@docusaurus/core": "2.0.0-beta.16",
|
|
25
|
+
"@docusaurus/plugin-content-blog": "2.0.0-beta.16",
|
|
26
|
+
"@docusaurus/plugin-content-docs": "2.0.0-beta.16",
|
|
27
|
+
"@docusaurus/plugin-content-pages": "2.0.0-beta.16",
|
|
28
|
+
"@docusaurus/theme-common": "2.0.0-beta.16",
|
|
29
|
+
"@docusaurus/theme-translations": "2.0.0-beta.16",
|
|
30
|
+
"@docusaurus/utils": "2.0.0-beta.16",
|
|
31
|
+
"@docusaurus/utils-common": "2.0.0-beta.16",
|
|
32
|
+
"@docusaurus/utils-validation": "2.0.0-beta.16",
|
|
33
|
+
"@mdx-js/react": "^1.6.22",
|
|
34
34
|
"clsx": "^1.1.1",
|
|
35
35
|
"copy-text-to-clipboard": "^3.0.1",
|
|
36
36
|
"infima": "0.2.0-alpha.37",
|
|
37
|
-
"lodash": "^4.17.
|
|
38
|
-
"postcss": "^8.
|
|
37
|
+
"lodash": "^4.17.21",
|
|
38
|
+
"postcss": "^8.4.6",
|
|
39
39
|
"prism-react-renderer": "^1.2.1",
|
|
40
|
-
"prismjs": "^1.
|
|
40
|
+
"prismjs": "^1.27.0",
|
|
41
41
|
"react-router-dom": "^5.2.0",
|
|
42
42
|
"rtlcss": "^3.3.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@docusaurus/module-type-aliases": "2.0.0-beta.
|
|
46
|
-
"@docusaurus/types": "2.0.0-beta.
|
|
47
|
-
"@types/mdx-js__react": "^1.5.
|
|
48
|
-
"@types/
|
|
49
|
-
"@types/
|
|
50
|
-
"@types/rtlcss": "^3.1.1",
|
|
45
|
+
"@docusaurus/module-type-aliases": "2.0.0-beta.16",
|
|
46
|
+
"@docusaurus/types": "2.0.0-beta.16",
|
|
47
|
+
"@types/mdx-js__react": "^1.5.5",
|
|
48
|
+
"@types/prismjs": "^1.26.0",
|
|
49
|
+
"@types/rtlcss": "^3.1.2",
|
|
51
50
|
"cross-env": "^7.0.3",
|
|
52
|
-
"fs-extra": "^10.0.
|
|
51
|
+
"fs-extra": "^10.0.1",
|
|
53
52
|
"react-test-renderer": "^17.0.2",
|
|
54
53
|
"utility-types": "^3.10.0"
|
|
55
54
|
},
|
|
@@ -60,5 +59,5 @@
|
|
|
60
59
|
"engines": {
|
|
61
60
|
"node": ">=14"
|
|
62
61
|
},
|
|
63
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "eb43c4d4f95a4fb97dc9bb9dc615413e0dc2e1e7"
|
|
64
63
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
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 type {SwizzleConfig} from '@docusaurus/types';
|
|
9
|
+
|
|
10
|
+
export default function getSwizzleConfig(): SwizzleConfig {
|
|
11
|
+
return {
|
|
12
|
+
components: {
|
|
13
|
+
CodeBlock: {
|
|
14
|
+
actions: {
|
|
15
|
+
wrap: 'safe',
|
|
16
|
+
eject: 'safe',
|
|
17
|
+
},
|
|
18
|
+
description:
|
|
19
|
+
'The component used to render multi-line code blocks, generally used in Markdown files.',
|
|
20
|
+
},
|
|
21
|
+
DocSidebar: {
|
|
22
|
+
actions: {
|
|
23
|
+
wrap: 'safe',
|
|
24
|
+
eject: 'unsafe', // too much technical code in sidebar, not very safe atm
|
|
25
|
+
},
|
|
26
|
+
description: 'The sidebar component on docs pages',
|
|
27
|
+
},
|
|
28
|
+
Footer: {
|
|
29
|
+
actions: {
|
|
30
|
+
wrap: 'safe',
|
|
31
|
+
eject: 'unsafe', // TODO split footer into smaller parts
|
|
32
|
+
},
|
|
33
|
+
description: "The footer component of you site's layout",
|
|
34
|
+
},
|
|
35
|
+
NotFound: {
|
|
36
|
+
actions: {
|
|
37
|
+
wrap: 'safe',
|
|
38
|
+
eject: 'safe',
|
|
39
|
+
},
|
|
40
|
+
description:
|
|
41
|
+
'The global 404 page of your site, meant to be ejected and customized',
|
|
42
|
+
},
|
|
43
|
+
SearchBar: {
|
|
44
|
+
actions: {
|
|
45
|
+
wrap: 'safe',
|
|
46
|
+
eject: 'safe',
|
|
47
|
+
},
|
|
48
|
+
// TODO how to describe this one properly?
|
|
49
|
+
// By default it's an empty placeholder for the user to fill
|
|
50
|
+
description:
|
|
51
|
+
'The search bar component of your site, appearing in the navbar.',
|
|
52
|
+
},
|
|
53
|
+
IconArrow: {
|
|
54
|
+
actions: {
|
|
55
|
+
wrap: 'safe',
|
|
56
|
+
eject: 'safe',
|
|
57
|
+
},
|
|
58
|
+
description: 'The arrow icon component',
|
|
59
|
+
},
|
|
60
|
+
IconEdit: {
|
|
61
|
+
actions: {
|
|
62
|
+
wrap: 'safe',
|
|
63
|
+
eject: 'safe',
|
|
64
|
+
},
|
|
65
|
+
description: 'The edit icon component',
|
|
66
|
+
},
|
|
67
|
+
IconMenu: {
|
|
68
|
+
actions: {
|
|
69
|
+
wrap: 'safe',
|
|
70
|
+
eject: 'safe',
|
|
71
|
+
},
|
|
72
|
+
description: 'The menu icon component',
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
'prism-include-languages': {
|
|
76
|
+
actions: {
|
|
77
|
+
wrap: 'forbidden', // not a component!
|
|
78
|
+
eject: 'safe',
|
|
79
|
+
},
|
|
80
|
+
description:
|
|
81
|
+
'The Prism languages to include for code block syntax highlighting. Meant to be ejected.',
|
|
82
|
+
},
|
|
83
|
+
MDXComponents: {
|
|
84
|
+
actions: {
|
|
85
|
+
wrap: 'forbidden', /// TODO allow wrapping objects???
|
|
86
|
+
eject: 'safe',
|
|
87
|
+
},
|
|
88
|
+
description:
|
|
89
|
+
'The MDX components to use for rendering MDX files. Meant to be ejected.',
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
// TODO should probably not even appear here
|
|
93
|
+
'NavbarItem/utils': {
|
|
94
|
+
actions: {
|
|
95
|
+
wrap: 'forbidden',
|
|
96
|
+
eject: 'forbidden',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -23,7 +23,7 @@ const ContextReplacementPlugin: typeof webpack.ContextReplacementPlugin =
|
|
|
23
23
|
requireFromDocusaurusCore('webpack/lib/ContextReplacementPlugin');
|
|
24
24
|
|
|
25
25
|
// Need to be inlined to prevent dark mode FOUC
|
|
26
|
-
// Make sure
|
|
26
|
+
// Make sure the key is the same as the one in `/theme/hooks/useTheme.js`
|
|
27
27
|
const ThemeStorageKey = 'theme';
|
|
28
28
|
const noFlashColorMode = ({
|
|
29
29
|
defaultMode,
|
|
@@ -64,15 +64,17 @@ const noFlashColorMode = ({
|
|
|
64
64
|
}
|
|
65
65
|
})();`;
|
|
66
66
|
|
|
67
|
-
// Duplicated constant. Unfortunately we can't import it from theme-common, as
|
|
67
|
+
// Duplicated constant. Unfortunately we can't import it from theme-common, as
|
|
68
|
+
// we need to support older nodejs versions without ESM support
|
|
68
69
|
// TODO: import from theme-common once we only support Node.js with ESM support
|
|
69
70
|
// + move all those announcementBar stuff there too
|
|
70
71
|
export const AnnouncementBarDismissStorageKey =
|
|
71
72
|
'docusaurus.announcement.dismiss';
|
|
72
73
|
const AnnouncementBarDismissDataAttribute =
|
|
73
74
|
'data-announcement-bar-initially-dismissed';
|
|
74
|
-
// We always render the announcement bar html on the server, to prevent layout
|
|
75
|
-
// The theme can use CSS + the data attribute to hide
|
|
75
|
+
// We always render the announcement bar html on the server, to prevent layout
|
|
76
|
+
// shifts on React hydration. The theme can use CSS + the data attribute to hide
|
|
77
|
+
// the announcement bar asap (before React hydration)
|
|
76
78
|
const AnnouncementBarInlineJavaScript = `
|
|
77
79
|
(function() {
|
|
78
80
|
function isDismissed() {
|
|
@@ -205,21 +207,5 @@ ${announcementBar ? AnnouncementBarInlineJavaScript : ''}
|
|
|
205
207
|
};
|
|
206
208
|
}
|
|
207
209
|
|
|
208
|
-
|
|
209
|
-
'CodeBlock',
|
|
210
|
-
'DocSidebar',
|
|
211
|
-
'Footer',
|
|
212
|
-
'NotFound',
|
|
213
|
-
'SearchBar',
|
|
214
|
-
'IconArrow',
|
|
215
|
-
'IconEdit',
|
|
216
|
-
'IconMenu',
|
|
217
|
-
'hooks/useTheme',
|
|
218
|
-
'prism-include-languages',
|
|
219
|
-
];
|
|
220
|
-
|
|
221
|
-
export function getSwizzleComponentList(): string[] {
|
|
222
|
-
return swizzleAllowedComponents;
|
|
223
|
-
}
|
|
224
|
-
|
|
210
|
+
export {default as getSwizzleConfig} from './getSwizzleConfig';
|
|
225
211
|
export {validateThemeConfig} from './validateThemeConfig';
|
|
@@ -13,7 +13,7 @@ import IconClose from '@theme/IconClose';
|
|
|
13
13
|
|
|
14
14
|
import styles from './styles.module.css';
|
|
15
15
|
|
|
16
|
-
function AnnouncementBar(): JSX.Element | null {
|
|
16
|
+
export default function AnnouncementBar(): JSX.Element | null {
|
|
17
17
|
const {isActive, close} = useAnnouncementBar();
|
|
18
18
|
const {announcementBar} = useThemeConfig();
|
|
19
19
|
|
|
@@ -51,5 +51,3 @@ function AnnouncementBar(): JSX.Element | null {
|
|
|
51
51
|
</div>
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
export default AnnouncementBar;
|
|
@@ -22,7 +22,9 @@ const threshold = 300;
|
|
|
22
22
|
// TODO proper detection is currently unreliable!
|
|
23
23
|
// see https://github.com/wessberg/scroll-behavior-polyfill/issues/16
|
|
24
24
|
const SupportsNativeSmoothScrolling = false;
|
|
25
|
-
// const SupportsNativeSmoothScrolling =
|
|
25
|
+
// const SupportsNativeSmoothScrolling =
|
|
26
|
+
// ExecutionEnvironment.canUseDOM &&
|
|
27
|
+
// 'scrollBehavior' in document.documentElement.style;
|
|
26
28
|
|
|
27
29
|
type CancelScrollTop = () => void;
|
|
28
30
|
|
|
@@ -44,13 +46,14 @@ function smoothScrollTopPolyfill(): CancelScrollTop {
|
|
|
44
46
|
}
|
|
45
47
|
rafRecursion();
|
|
46
48
|
|
|
47
|
-
// Break the recursion
|
|
48
|
-
//
|
|
49
|
+
// Break the recursion. Prevents the user from "fighting" against that
|
|
50
|
+
// recursion producing a weird UX
|
|
49
51
|
return () => raf && cancelAnimationFrame(raf);
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
type UseSmoothScrollTopReturn = {
|
|
53
|
-
// We use a cancel function because the non-native smooth scroll-top
|
|
55
|
+
// We use a cancel function because the non-native smooth scroll-top
|
|
56
|
+
// implementation must be interrupted if user scroll down
|
|
54
57
|
smoothScrollTop: () => void;
|
|
55
58
|
cancelScrollToTop: CancelScrollTop;
|
|
56
59
|
};
|
|
@@ -70,7 +73,7 @@ function useSmoothScrollToTop(): UseSmoothScrollTopReturn {
|
|
|
70
73
|
};
|
|
71
74
|
}
|
|
72
75
|
|
|
73
|
-
function BackToTopButton(): JSX.Element {
|
|
76
|
+
export default function BackToTopButton(): JSX.Element {
|
|
74
77
|
const [show, setShow] = useState(false);
|
|
75
78
|
const isFocusedAnchor = useRef(false);
|
|
76
79
|
const {smoothScrollTop, cancelScrollToTop} = useSmoothScrollToTop();
|
|
@@ -138,5 +141,3 @@ function BackToTopButton(): JSX.Element {
|
|
|
138
141
|
/>
|
|
139
142
|
);
|
|
140
143
|
}
|
|
141
|
-
|
|
142
|
-
export default BackToTopButton;
|
|
@@ -13,12 +13,13 @@
|
|
|
13
13
|
background-color: var(--ifm-color-emphasis-200);
|
|
14
14
|
width: 3rem;
|
|
15
15
|
height: 3rem;
|
|
16
|
-
z-index: var(--ifm-z-index-fixed);
|
|
16
|
+
z-index: calc(var(--ifm-z-index-fixed) - 1);
|
|
17
17
|
box-shadow: var(--ifm-global-shadow-lw);
|
|
18
18
|
transition: all var(--ifm-transition-fast)
|
|
19
19
|
var(--ifm-transition-timing-default);
|
|
20
20
|
opacity: 0;
|
|
21
21
|
transform: scale(0);
|
|
22
|
+
visibility: hidden;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
.backToTopButton::after {
|
|
@@ -39,4 +40,5 @@
|
|
|
39
40
|
.backToTopButtonShow {
|
|
40
41
|
opacity: 1;
|
|
41
42
|
transform: scale(1);
|
|
43
|
+
visibility: visible;
|
|
42
44
|
}
|
|
@@ -12,7 +12,7 @@ import BlogSidebar from '@theme/BlogSidebar';
|
|
|
12
12
|
|
|
13
13
|
import type {Props} from '@theme/BlogLayout';
|
|
14
14
|
|
|
15
|
-
function BlogLayout(props: Props): JSX.Element {
|
|
15
|
+
export default function BlogLayout(props: Props): JSX.Element {
|
|
16
16
|
const {sidebar, toc, children, ...layoutProps} = props;
|
|
17
17
|
const hasSidebar = sidebar && sidebar.items.length > 0;
|
|
18
18
|
|
|
@@ -40,5 +40,3 @@ function BlogLayout(props: Props): JSX.Element {
|
|
|
40
40
|
</Layout>
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
export default BlogLayout;
|
|
@@ -14,7 +14,7 @@ import BlogListPaginator from '@theme/BlogListPaginator';
|
|
|
14
14
|
import type {Props} from '@theme/BlogListPage';
|
|
15
15
|
import {ThemeClassNames} from '@docusaurus/theme-common';
|
|
16
16
|
|
|
17
|
-
function BlogListPage(props: Props): JSX.Element {
|
|
17
|
+
export default function BlogListPage(props: Props): JSX.Element {
|
|
18
18
|
const {metadata, items, sidebar} = props;
|
|
19
19
|
const {
|
|
20
20
|
siteConfig: {title: siteTitle},
|
|
@@ -48,5 +48,3 @@ function BlogListPage(props: Props): JSX.Element {
|
|
|
48
48
|
</BlogLayout>
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
export default BlogListPage;
|