@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
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import Link from '@docusaurus/Link';
|
|
9
|
+
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
10
|
+
import IconExternalLink from '@theme/IconExternalLink';
|
|
11
|
+
import isInternalUrl from '@docusaurus/isInternalUrl';
|
|
12
|
+
import {isRegexpStringMatch} from '@docusaurus/theme-common';
|
|
13
|
+
const dropdownLinkActiveClass = 'dropdown__link--active';
|
|
14
|
+
export default function NavbarNavLink({
|
|
15
|
+
activeBasePath,
|
|
16
|
+
activeBaseRegex,
|
|
17
|
+
to,
|
|
18
|
+
href,
|
|
19
|
+
label,
|
|
20
|
+
activeClassName = '',
|
|
21
|
+
prependBaseUrlToHref,
|
|
22
|
+
...props
|
|
23
|
+
}) {
|
|
24
|
+
// TODO all this seems hacky
|
|
25
|
+
// {to: 'version'} should probably be forbidden, in favor of {to: '/version'}
|
|
26
|
+
const toUrl = useBaseUrl(to);
|
|
27
|
+
const activeBaseUrl = useBaseUrl(activeBasePath);
|
|
28
|
+
const normalizedHref = useBaseUrl(href, {
|
|
29
|
+
forcePrependBaseUrl: true,
|
|
30
|
+
});
|
|
31
|
+
const isExternalLink = label && href && !isInternalUrl(href);
|
|
32
|
+
const isDropdownLink = activeClassName === dropdownLinkActiveClass;
|
|
33
|
+
return (
|
|
34
|
+
<Link
|
|
35
|
+
{...(href
|
|
36
|
+
? {
|
|
37
|
+
href: prependBaseUrlToHref ? normalizedHref : href,
|
|
38
|
+
}
|
|
39
|
+
: {
|
|
40
|
+
isNavLink: true,
|
|
41
|
+
activeClassName: !props.className?.includes(activeClassName)
|
|
42
|
+
? activeClassName
|
|
43
|
+
: '',
|
|
44
|
+
to: toUrl,
|
|
45
|
+
...(activeBasePath || activeBaseRegex
|
|
46
|
+
? {
|
|
47
|
+
isActive: (_match, location) =>
|
|
48
|
+
activeBaseRegex
|
|
49
|
+
? isRegexpStringMatch(activeBaseRegex, location.pathname)
|
|
50
|
+
: location.pathname.startsWith(activeBaseUrl),
|
|
51
|
+
}
|
|
52
|
+
: null),
|
|
53
|
+
})}
|
|
54
|
+
{...props}>
|
|
55
|
+
{isExternalLink ? (
|
|
56
|
+
<span>
|
|
57
|
+
{label}
|
|
58
|
+
<IconExternalLink
|
|
59
|
+
{...(isDropdownLink && {
|
|
60
|
+
width: 12,
|
|
61
|
+
height: 12,
|
|
62
|
+
})}
|
|
63
|
+
/>
|
|
64
|
+
</span>
|
|
65
|
+
) : (
|
|
66
|
+
label
|
|
67
|
+
)}
|
|
68
|
+
</Link>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -22,6 +22,7 @@ const NavbarItemComponents = {
|
|
|
22
22
|
docsVersionDropdown: () =>
|
|
23
23
|
require('@theme/NavbarItem/DocsVersionDropdownNavbarItem').default,
|
|
24
24
|
doc: () => require('@theme/NavbarItem/DocNavbarItem').default,
|
|
25
|
+
docSidebar: () => require('@theme/NavbarItem/DocSidebarNavbarItem').default,
|
|
25
26
|
/* eslint-enable @typescript-eslint/no-var-requires, global-require */
|
|
26
27
|
};
|
|
27
28
|
|
|
@@ -45,8 +46,6 @@ function getComponentType(type, isDropdown) {
|
|
|
45
46
|
return type;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
export const getInfimaActiveClassName = (mobile) =>
|
|
49
|
-
mobile ? 'menu__link--active' : 'navbar__link--active';
|
|
50
49
|
export default function NavbarItem({type, ...props}) {
|
|
51
50
|
const componentType = getComponentType(type, props.items !== undefined);
|
|
52
51
|
const NavbarItemComponent = getNavbarItemComponent(componentType);
|
|
@@ -4,7 +4,6 @@
|
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
7
|
+
// eslint-disable-next-line import/no-named-export
|
|
8
|
+
export const getInfimaActiveClassName = (mobile) =>
|
|
9
|
+
mobile ? 'menu__link--active' : 'navbar__link--active';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import Link from '@docusaurus/Link';
|
|
9
|
+
|
|
10
|
+
function PaginatorNavLink(props) {
|
|
11
|
+
const {permalink, title, subLabel} = props;
|
|
12
|
+
return (
|
|
13
|
+
<Link className="pagination-nav__link" to={permalink}>
|
|
14
|
+
{subLabel && <div className="pagination-nav__sublabel">{subLabel}</div>}
|
|
15
|
+
<div className="pagination-nav__label">{title}</div>
|
|
16
|
+
</Link>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default PaginatorNavLink;
|
|
@@ -37,7 +37,7 @@ function SkipToContent() {
|
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
return (
|
|
40
|
-
<div ref={containerRef}>
|
|
40
|
+
<div ref={containerRef} role="region">
|
|
41
41
|
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
42
42
|
<a href="#" className={styles.skipToContent} onClick={handleSkip}>
|
|
43
43
|
<Translate
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
width: 100%;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
.tocCollapsibleButton
|
|
23
|
+
.tocCollapsibleButton::after {
|
|
24
24
|
content: '';
|
|
25
25
|
background: var(--ifm-menu-link-sublist-icon) 50% 50% / 2rem 2rem no-repeat;
|
|
26
26
|
filter: var(--ifm-menu-link-sublist-icon-filter);
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
display: block;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
.tocCollapsibleExpanded .tocCollapsibleButton
|
|
48
|
+
.tocCollapsibleExpanded .tocCollapsibleButton::after {
|
|
49
49
|
transform: none;
|
|
50
50
|
}
|
|
@@ -8,8 +8,10 @@ import React from 'react';
|
|
|
8
8
|
import renderer from 'react-test-renderer';
|
|
9
9
|
import Tabs from '../index';
|
|
10
10
|
import TabItem from '../../TabItem';
|
|
11
|
-
import
|
|
12
|
-
|
|
11
|
+
import {
|
|
12
|
+
TabGroupChoiceProvider,
|
|
13
|
+
ScrollControllerProvider,
|
|
14
|
+
} from '@docusaurus/theme-common';
|
|
13
15
|
describe('Tabs', () => {
|
|
14
16
|
test('Should reject bad Tabs child', () => {
|
|
15
17
|
expect(() => {
|
|
@@ -55,7 +57,7 @@ describe('Tabs', () => {
|
|
|
55
57
|
expect(() => {
|
|
56
58
|
renderer.create(
|
|
57
59
|
<ScrollControllerProvider>
|
|
58
|
-
<
|
|
60
|
+
<TabGroupChoiceProvider>
|
|
59
61
|
<Tabs>
|
|
60
62
|
<TabItem value="v1">Tab 1</TabItem>
|
|
61
63
|
<TabItem value="v2">Tab 2</TabItem>
|
|
@@ -112,7 +114,7 @@ describe('Tabs', () => {
|
|
|
112
114
|
Tab 2
|
|
113
115
|
</TabItem>
|
|
114
116
|
</Tabs>
|
|
115
|
-
</
|
|
117
|
+
</TabGroupChoiceProvider>
|
|
116
118
|
</ScrollControllerProvider>,
|
|
117
119
|
);
|
|
118
120
|
}).not.toThrow(); // TODO Better Jest infrastructure to mock the Layout
|
|
@@ -123,7 +125,7 @@ describe('Tabs', () => {
|
|
|
123
125
|
const tabs = ['Apple', 'Banana', 'Carrot'];
|
|
124
126
|
renderer.create(
|
|
125
127
|
<ScrollControllerProvider>
|
|
126
|
-
<
|
|
128
|
+
<TabGroupChoiceProvider>
|
|
127
129
|
<Tabs
|
|
128
130
|
values={tabs.map((t, idx) => ({
|
|
129
131
|
label: t,
|
|
@@ -134,7 +136,7 @@ describe('Tabs', () => {
|
|
|
134
136
|
<TabItem value={idx}>{t}</TabItem>
|
|
135
137
|
))}
|
|
136
138
|
</Tabs>
|
|
137
|
-
</
|
|
139
|
+
</TabGroupChoiceProvider>
|
|
138
140
|
</ScrollControllerProvider>,
|
|
139
141
|
);
|
|
140
142
|
}).not.toThrow();
|
|
@@ -6,8 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React, {useState, cloneElement, Children, isValidElement} from 'react';
|
|
8
8
|
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
9
|
-
import
|
|
10
|
-
|
|
9
|
+
import {
|
|
10
|
+
useScrollPositionBlocker,
|
|
11
|
+
duplicates,
|
|
12
|
+
useTabGroupChoice,
|
|
13
|
+
} from '@docusaurus/theme-common';
|
|
11
14
|
import clsx from 'clsx';
|
|
12
15
|
import styles from './styles.module.css'; // A very rough duck type, but good enough to guard against mistakes while
|
|
13
16
|
// allowing customization
|
|
@@ -72,7 +75,7 @@ function TabsComponent(props) {
|
|
|
72
75
|
);
|
|
73
76
|
}
|
|
74
77
|
|
|
75
|
-
const {tabGroupChoices, setTabGroupChoices} =
|
|
78
|
+
const {tabGroupChoices, setTabGroupChoices} = useTabGroupChoice();
|
|
76
79
|
const [selectedValue, setSelectedValue] = useState(defaultValue);
|
|
77
80
|
const tabRefs = [];
|
|
78
81
|
const {blockElementScrollPositionUntilNextRender} =
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
border-left: 0;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
.tagWithCount
|
|
37
|
-
.tagWithCount
|
|
36
|
+
.tagWithCount::before,
|
|
37
|
+
.tagWithCount::after {
|
|
38
38
|
content: '';
|
|
39
39
|
position: absolute;
|
|
40
40
|
top: 50%;
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
transition: inherit;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
.tagWithCount
|
|
45
|
+
.tagWithCount::before {
|
|
46
46
|
right: 100%;
|
|
47
47
|
transform: translate(50%, -50%) rotate(-45deg);
|
|
48
48
|
width: 1.18rem;
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
border-bottom: 0;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
.tagWithCount
|
|
54
|
+
.tagWithCount::after {
|
|
55
55
|
left: 0;
|
|
56
56
|
transform: translateY(-50%);
|
|
57
57
|
width: 0.5rem;
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
10
|
-
import
|
|
10
|
+
import {useColorMode} from '@docusaurus/theme-common';
|
|
11
11
|
import styles from './styles.module.css';
|
|
12
12
|
|
|
13
13
|
function ThemedImage(props) {
|
|
14
14
|
const isBrowser = useIsBrowser();
|
|
15
|
-
const {isDarkTheme} =
|
|
15
|
+
const {isDarkTheme} = useColorMode();
|
|
16
16
|
const {sources, className, alt = '', ...propsRest} = props;
|
|
17
17
|
const clientThemes = isDarkTheme ? ['dark'] : ['light'];
|
|
18
18
|
const renderedSourceNames = isBrowser
|
|
@@ -39,16 +39,16 @@
|
|
|
39
39
|
position: absolute;
|
|
40
40
|
width: 14px;
|
|
41
41
|
height: 10px;
|
|
42
|
-
top:
|
|
43
|
-
bottom:
|
|
42
|
+
top: 0;
|
|
43
|
+
bottom: 0;
|
|
44
44
|
margin: auto 0;
|
|
45
45
|
left: 8px;
|
|
46
46
|
opacity: 0;
|
|
47
47
|
transition: opacity 0.25s ease;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
.
|
|
50
|
+
.toggleChecked .toggleTrackCheck,
|
|
51
|
+
[data-theme='dark'] .toggle .toggleTrackCheck {
|
|
52
52
|
opacity: 1;
|
|
53
53
|
transition: opacity 0.25s ease;
|
|
54
54
|
}
|
|
@@ -57,16 +57,16 @@
|
|
|
57
57
|
position: absolute;
|
|
58
58
|
width: 10px;
|
|
59
59
|
height: 10px;
|
|
60
|
-
top:
|
|
61
|
-
bottom:
|
|
60
|
+
top: 0;
|
|
61
|
+
bottom: 0;
|
|
62
62
|
margin: auto 0;
|
|
63
63
|
right: 10px;
|
|
64
64
|
opacity: 1;
|
|
65
65
|
transition: opacity 0.25s ease;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
.
|
|
68
|
+
.toggleChecked .toggleTrackX,
|
|
69
|
+
[data-theme='dark'] .toggle .toggleTrackX {
|
|
70
70
|
opacity: 0;
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -82,18 +82,19 @@
|
|
|
82
82
|
transition: all 0.25s ease;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
[data-theme='dark'] .toggle .toggleTrackThumb,
|
|
86
|
-
.toggleChecked .toggleTrackThumb {
|
|
87
|
-
left: 27px;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
85
|
.toggleFocused .toggleTrackThumb,
|
|
91
86
|
.toggle:hover .toggleTrackThumb {
|
|
92
|
-
box-shadow:
|
|
87
|
+
box-shadow: 0 0 2px 3px var(--ifm-color-primary);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* stylelint-disable-next-line no-descending-specificity */
|
|
91
|
+
.toggleChecked .toggleTrackThumb,
|
|
92
|
+
[data-theme='dark'] .toggle .toggleTrackThumb {
|
|
93
|
+
left: 27px;
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
.toggle:active:not(.toggleDisabled) .toggleTrackThumb {
|
|
96
|
-
box-shadow:
|
|
97
|
+
box-shadow: 0 0 5px 5px var(--ifm-color-primary);
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
.toggleIcon {
|
|
@@ -10,12 +10,19 @@ import siteConfig from '@generated/docusaurus.config';
|
|
|
10
10
|
const prismIncludeLanguages = (PrismObject) => {
|
|
11
11
|
if (ExecutionEnvironment.canUseDOM) {
|
|
12
12
|
const {
|
|
13
|
-
themeConfig: {prism
|
|
13
|
+
themeConfig: {prism},
|
|
14
14
|
} = siteConfig;
|
|
15
|
-
const {additionalLanguages
|
|
15
|
+
const {additionalLanguages} = prism; // Prism components work on the Prism instance on the window, while
|
|
16
|
+
// prism-react-renderer uses its own Prism instance. We temporarily mount
|
|
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
|
+
|
|
16
22
|
window.Prism = PrismObject;
|
|
17
23
|
additionalLanguages.forEach((lang) => {
|
|
18
|
-
|
|
24
|
+
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
25
|
+
require(`prismjs/components/prism-${lang}`);
|
|
19
26
|
});
|
|
20
27
|
delete window.Prism;
|
|
21
28
|
}
|
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.15",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -18,24 +18,21 @@
|
|
|
18
18
|
"watch": "concurrently --names \"lib,lib-next,tsc\" --kill-others \"yarn babel:lib --watch\" \"yarn babel:lib-next --watch\" \"yarn tsc --watch\"",
|
|
19
19
|
"babel:lib": "cross-env BABEL_ENV=lib babel src -d lib --extensions \".tsx,.ts\" --ignore \"**/*.d.ts\" --copy-files",
|
|
20
20
|
"babel:lib-next": "cross-env BABEL_ENV=lib-next babel src -d lib-next --extensions \".tsx,.ts\" --ignore \"**/*.d.ts\" --copy-files",
|
|
21
|
-
"format": "prettier --config ../../.prettierrc --
|
|
22
|
-
"format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\"",
|
|
23
|
-
"update-code-translations": "node -e 'require(\"./update-code-translations.js\").run()'"
|
|
21
|
+
"format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
|
|
24
22
|
},
|
|
25
23
|
"dependencies": {
|
|
26
|
-
"@docusaurus/core": "2.0.0-beta.
|
|
27
|
-
"@docusaurus/plugin-content-blog": "2.0.0-beta.
|
|
28
|
-
"@docusaurus/plugin-content-docs": "2.0.0-beta.
|
|
29
|
-
"@docusaurus/plugin-content-pages": "2.0.0-beta.
|
|
30
|
-
"@docusaurus/theme-common": "2.0.0-beta.
|
|
31
|
-
"@docusaurus/theme-translations": "2.0.0-beta.
|
|
32
|
-
"@docusaurus/utils": "2.0.0-beta.
|
|
33
|
-
"@docusaurus/utils-
|
|
34
|
-
"@
|
|
24
|
+
"@docusaurus/core": "2.0.0-beta.15",
|
|
25
|
+
"@docusaurus/plugin-content-blog": "2.0.0-beta.15",
|
|
26
|
+
"@docusaurus/plugin-content-docs": "2.0.0-beta.15",
|
|
27
|
+
"@docusaurus/plugin-content-pages": "2.0.0-beta.15",
|
|
28
|
+
"@docusaurus/theme-common": "2.0.0-beta.15",
|
|
29
|
+
"@docusaurus/theme-translations": "2.0.0-beta.15",
|
|
30
|
+
"@docusaurus/utils": "2.0.0-beta.15",
|
|
31
|
+
"@docusaurus/utils-common": "2.0.0-beta.15",
|
|
32
|
+
"@docusaurus/utils-validation": "2.0.0-beta.15",
|
|
35
33
|
"@mdx-js/react": "^1.6.21",
|
|
36
34
|
"clsx": "^1.1.1",
|
|
37
35
|
"copy-text-to-clipboard": "^3.0.1",
|
|
38
|
-
"globby": "^11.0.2",
|
|
39
36
|
"infima": "0.2.0-alpha.37",
|
|
40
37
|
"lodash": "^4.17.20",
|
|
41
38
|
"postcss": "^8.3.7",
|
|
@@ -45,11 +42,13 @@
|
|
|
45
42
|
"rtlcss": "^3.3.0"
|
|
46
43
|
},
|
|
47
44
|
"devDependencies": {
|
|
48
|
-
"@docusaurus/module-type-aliases": "2.0.0-beta.
|
|
49
|
-
"@docusaurus/types": "2.0.0-beta.
|
|
45
|
+
"@docusaurus/module-type-aliases": "2.0.0-beta.15",
|
|
46
|
+
"@docusaurus/types": "2.0.0-beta.15",
|
|
50
47
|
"@types/mdx-js__react": "^1.5.4",
|
|
51
48
|
"@types/parse-numeric-range": "^0.0.1",
|
|
49
|
+
"@types/prismjs": "^1.16.2",
|
|
52
50
|
"@types/rtlcss": "^3.1.1",
|
|
51
|
+
"cross-env": "^7.0.3",
|
|
53
52
|
"fs-extra": "^10.0.0",
|
|
54
53
|
"react-test-renderer": "^17.0.2",
|
|
55
54
|
"utility-types": "^3.10.0"
|
|
@@ -61,5 +60,5 @@
|
|
|
61
60
|
"engines": {
|
|
62
61
|
"node": ">=14"
|
|
63
62
|
},
|
|
64
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "6cfad16436c07d8d11e5c2e1486dc59afd483e33"
|
|
65
64
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import type {LoadContext, Plugin, PostCssOptions} from '@docusaurus/types';
|
|
9
9
|
import type {ThemeConfig} from '@docusaurus/theme-common';
|
|
10
10
|
import {getTranslationFiles, translateThemeConfig} from './translations';
|
|
11
11
|
import path from 'path';
|
|
@@ -14,13 +14,13 @@ import type {Plugin as PostCssPlugin} from 'postcss';
|
|
|
14
14
|
import rtlcss from 'rtlcss';
|
|
15
15
|
import {readDefaultCodeTranslationMessages} from '@docusaurus/theme-translations';
|
|
16
16
|
import type {Options} from '@docusaurus/theme-classic';
|
|
17
|
+
import type webpack from 'webpack';
|
|
17
18
|
|
|
18
19
|
const requireFromDocusaurusCore = createRequire(
|
|
19
20
|
require.resolve('@docusaurus/core/package.json'),
|
|
20
21
|
);
|
|
21
|
-
const ContextReplacementPlugin =
|
|
22
|
-
'webpack/lib/ContextReplacementPlugin'
|
|
23
|
-
);
|
|
22
|
+
const ContextReplacementPlugin: typeof webpack.ContextReplacementPlugin =
|
|
23
|
+
requireFromDocusaurusCore('webpack/lib/ContextReplacementPlugin');
|
|
24
24
|
|
|
25
25
|
// Need to be inlined to prevent dark mode FOUC
|
|
26
26
|
// Make sure that the 'storageKey' is the same as the one in `/theme/hooks/useTheme.js`
|
|
@@ -91,7 +91,7 @@ function getInfimaCSSFile(direction: string) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
export default function docusaurusThemeClassic(
|
|
94
|
-
context:
|
|
94
|
+
context: LoadContext,
|
|
95
95
|
options: Options,
|
|
96
96
|
): Plugin<void> {
|
|
97
97
|
const {
|
|
@@ -110,22 +110,12 @@ export default function docusaurusThemeClassic(
|
|
|
110
110
|
return {
|
|
111
111
|
name: 'docusaurus-theme-classic',
|
|
112
112
|
|
|
113
|
-
/*
|
|
114
|
-
Does not seem needed: webpack can already hot reload theme files
|
|
115
|
-
getPathsToWatch() {
|
|
116
|
-
return [
|
|
117
|
-
path.join(__dirname, '..', 'lib'),
|
|
118
|
-
path.join(__dirname, '..', 'lib-next'),
|
|
119
|
-
];
|
|
120
|
-
},
|
|
121
|
-
*/
|
|
122
|
-
|
|
123
113
|
getThemePath() {
|
|
124
|
-
return path.join(__dirname, '
|
|
114
|
+
return path.join(__dirname, '../lib-next/theme');
|
|
125
115
|
},
|
|
126
116
|
|
|
127
117
|
getTypeScriptThemePath() {
|
|
128
|
-
return path.resolve(__dirname, '
|
|
118
|
+
return path.resolve(__dirname, '../src/theme');
|
|
129
119
|
},
|
|
130
120
|
|
|
131
121
|
getTranslationFiles: async () => getTranslationFiles({themeConfig}),
|
|
@@ -167,11 +157,10 @@ export default function docusaurusThemeClassic(
|
|
|
167
157
|
.join('|');
|
|
168
158
|
|
|
169
159
|
return {
|
|
170
|
-
ignoreWarnings: [
|
|
171
|
-
// See https://github.com/facebook/docusaurus/pull/3382
|
|
172
|
-
(e) => e.message.includes("Can't resolve '@theme-init/hooks/useDocs"),
|
|
173
|
-
],
|
|
174
160
|
plugins: [
|
|
161
|
+
// This allows better optimization by only bundling those components
|
|
162
|
+
// that the user actually needs, because the modules are dynamically
|
|
163
|
+
// required and can't be known during compile time.
|
|
175
164
|
new ContextReplacementPlugin(
|
|
176
165
|
/prismjs[\\/]components$/,
|
|
177
166
|
new RegExp(`^./(${prismLanguages})$`),
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import Link from '@docusaurus/Link';
|
|
10
9
|
import Translate, {translate} from '@docusaurus/Translate';
|
|
10
|
+
import PaginatorNavLink from '@theme/PaginatorNavLink';
|
|
11
11
|
import type {Props} from '@theme/BlogListPaginator';
|
|
12
12
|
|
|
13
13
|
function BlogListPaginator(props: Props): JSX.Element {
|
|
@@ -24,30 +24,30 @@ function BlogListPaginator(props: Props): JSX.Element {
|
|
|
24
24
|
})}>
|
|
25
25
|
<div className="pagination-nav__item">
|
|
26
26
|
{previousPage && (
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
<PaginatorNavLink
|
|
28
|
+
permalink={previousPage}
|
|
29
|
+
title={
|
|
30
30
|
<Translate
|
|
31
31
|
id="theme.blog.paginator.newerEntries"
|
|
32
32
|
description="The label used to navigate to the newer blog posts page (previous page)">
|
|
33
33
|
Newer Entries
|
|
34
34
|
</Translate>
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
}
|
|
36
|
+
/>
|
|
37
37
|
)}
|
|
38
38
|
</div>
|
|
39
39
|
<div className="pagination-nav__item pagination-nav__item--next">
|
|
40
40
|
{nextPage && (
|
|
41
|
-
<
|
|
42
|
-
|
|
41
|
+
<PaginatorNavLink
|
|
42
|
+
permalink={nextPage}
|
|
43
|
+
title={
|
|
43
44
|
<Translate
|
|
44
45
|
id="theme.blog.paginator.olderEntries"
|
|
45
46
|
description="The label used to navigate to the older blog posts page (next page)">
|
|
46
47
|
Older Entries
|
|
47
|
-
</Translate>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
</Link>
|
|
48
|
+
</Translate>
|
|
49
|
+
}
|
|
50
|
+
/>
|
|
51
51
|
)}
|
|
52
52
|
</div>
|
|
53
53
|
</nav>
|
|
@@ -22,7 +22,7 @@ function BlogPostAuthor({author}: Props): JSX.Element {
|
|
|
22
22
|
)}
|
|
23
23
|
|
|
24
24
|
{
|
|
25
|
-
// Note: only legacy author
|
|
25
|
+
// Note: only legacy author front matter allow empty name (not frontMatter.authors)
|
|
26
26
|
name && (
|
|
27
27
|
<div
|
|
28
28
|
className="avatar__intro"
|
|
@@ -21,10 +21,20 @@ export default function BlogPostAuthors({
|
|
|
21
21
|
if (authorsCount === 0) {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
|
+
const imageOnly = authors.every(({name}) => !name);
|
|
24
25
|
return (
|
|
25
|
-
<div
|
|
26
|
+
<div
|
|
27
|
+
className={clsx(
|
|
28
|
+
'margin-top--md margin-bottom--sm',
|
|
29
|
+
imageOnly ? styles.imageOnlyAuthorRow : 'row',
|
|
30
|
+
)}>
|
|
26
31
|
{authors.map((author, idx) => (
|
|
27
|
-
<div
|
|
32
|
+
<div
|
|
33
|
+
className={clsx(
|
|
34
|
+
!imageOnly && 'col col--6',
|
|
35
|
+
imageOnly ? styles.imageOnlyAuthorCol : styles.authorCol,
|
|
36
|
+
)}
|
|
37
|
+
key={idx}>
|
|
28
38
|
<BlogPostAuthor
|
|
29
39
|
author={{
|
|
30
40
|
...author,
|