@docusaurus/theme-classic 2.0.0-rc.1 → 2.1.0
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 +7 -0
- package/lib/theme/AnnouncementBar/CloseButton/index.d.ts +9 -0
- package/lib/theme/AnnouncementBar/CloseButton/index.js +26 -0
- package/lib/theme/AnnouncementBar/CloseButton/styles.module.css +11 -0
- package/lib/theme/AnnouncementBar/Content/index.d.ts +9 -0
- package/lib/theme/AnnouncementBar/Content/index.js +23 -0
- package/lib/theme/AnnouncementBar/Content/styles.module.css +17 -0
- package/lib/theme/AnnouncementBar/index.js +10 -23
- package/lib/theme/AnnouncementBar/styles.module.css +2 -11
- package/lib/theme/CodeBlock/Line/styles.module.css +1 -0
- package/lib/theme/DocCardList/index.d.ts +1 -1
- package/lib/theme/DocCardList/index.js +14 -11
- package/lib/theme/DocPage/index.js +24 -7
- package/lib/theme/DocSidebarItem/Category/index.js +1 -1
- package/lib/theme/DocSidebarItem/Link/index.js +2 -1
- package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js +1 -0
- package/lib/theme/SkipToContent/index.js +5 -2
- package/lib/theme/Tag/styles.module.css +1 -1
- package/package.json +14 -16
- package/src/getSwizzleConfig.ts +8 -0
- package/src/theme/AnnouncementBar/CloseButton/index.tsx +31 -0
- package/src/theme/AnnouncementBar/CloseButton/styles.module.css +11 -0
- package/src/theme/AnnouncementBar/Content/index.tsx +28 -0
- package/src/theme/AnnouncementBar/Content/styles.module.css +17 -0
- package/src/theme/AnnouncementBar/index.tsx +10 -26
- package/src/theme/AnnouncementBar/styles.module.css +2 -11
- package/src/theme/CodeBlock/Line/styles.module.css +1 -0
- package/src/theme/DocCardList/index.tsx +14 -12
- package/src/theme/DocPage/index.tsx +25 -7
- package/src/theme/DocSidebarItem/Category/index.tsx +1 -1
- package/src/theme/DocSidebarItem/Link/index.tsx +2 -1
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +1 -0
- package/src/theme/SkipToContent/index.tsx +5 -2
- package/src/theme/Tag/styles.module.css +1 -1
- package/src/theme-classic.d.ts +17 -1
package/lib/getSwizzleConfig.js
CHANGED
|
@@ -24,6 +24,13 @@ function getSwizzleConfig() {
|
|
|
24
24
|
},
|
|
25
25
|
description: 'The color mode toggle to switch between light and dark mode.',
|
|
26
26
|
},
|
|
27
|
+
DocCardList: {
|
|
28
|
+
actions: {
|
|
29
|
+
eject: 'safe',
|
|
30
|
+
wrap: 'safe',
|
|
31
|
+
},
|
|
32
|
+
description: 'The component responsible for rendering a list of sidebar items cards.\nNotable used on the category generated-index pages.',
|
|
33
|
+
},
|
|
27
34
|
DocSidebar: {
|
|
28
35
|
actions: {
|
|
29
36
|
eject: 'unsafe',
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
/// <reference types="react" />
|
|
8
|
+
import type { Props } from '@theme/AnnouncementBar/CloseButton';
|
|
9
|
+
export default function AnnouncementBarCloseButton(props: Props): JSX.Element | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
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 clsx from 'clsx';
|
|
9
|
+
import {translate} from '@docusaurus/Translate';
|
|
10
|
+
import IconClose from '@theme/Icon/Close';
|
|
11
|
+
import styles from './styles.module.css';
|
|
12
|
+
export default function AnnouncementBarCloseButton(props) {
|
|
13
|
+
return (
|
|
14
|
+
<button
|
|
15
|
+
type="button"
|
|
16
|
+
aria-label={translate({
|
|
17
|
+
id: 'theme.AnnouncementBar.closeButtonAriaLabel',
|
|
18
|
+
message: 'Close',
|
|
19
|
+
description: 'The ARIA label for close button of announcement bar',
|
|
20
|
+
})}
|
|
21
|
+
{...props}
|
|
22
|
+
className={clsx('clean-btn close', styles.closeButton, props.className)}>
|
|
23
|
+
<IconClose width={14} height={14} strokeWidth={3.1} />
|
|
24
|
+
</button>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
/// <reference types="react" />
|
|
8
|
+
import type { Props } from '@theme/AnnouncementBar/Content';
|
|
9
|
+
export default function AnnouncementBarContent(props: Props): JSX.Element | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
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 clsx from 'clsx';
|
|
9
|
+
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
10
|
+
import styles from './styles.module.css';
|
|
11
|
+
export default function AnnouncementBarContent(props) {
|
|
12
|
+
const {announcementBar} = useThemeConfig();
|
|
13
|
+
const {content} = announcementBar;
|
|
14
|
+
return (
|
|
15
|
+
<div
|
|
16
|
+
{...props}
|
|
17
|
+
className={clsx(styles.content, props.className)}
|
|
18
|
+
// Developer provided the HTML, so assume it's safe.
|
|
19
|
+
// eslint-disable-next-line react/no-danger
|
|
20
|
+
dangerouslySetInnerHTML={{__html: content}}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
.content {
|
|
9
|
+
font-size: 85%;
|
|
10
|
+
text-align: center;
|
|
11
|
+
padding: 5px 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.content a {
|
|
15
|
+
color: inherit;
|
|
16
|
+
text-decoration: underline;
|
|
17
|
+
}
|
|
@@ -5,44 +5,31 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import clsx from 'clsx';
|
|
9
8
|
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
10
9
|
import {useAnnouncementBar} from '@docusaurus/theme-common/internal';
|
|
11
|
-
import
|
|
12
|
-
import
|
|
10
|
+
import AnnouncementBarCloseButton from '@theme/AnnouncementBar/CloseButton';
|
|
11
|
+
import AnnouncementBarContent from '@theme/AnnouncementBar/Content';
|
|
13
12
|
import styles from './styles.module.css';
|
|
14
13
|
export default function AnnouncementBar() {
|
|
15
|
-
const {isActive, close} = useAnnouncementBar();
|
|
16
14
|
const {announcementBar} = useThemeConfig();
|
|
15
|
+
const {isActive, close} = useAnnouncementBar();
|
|
17
16
|
if (!isActive) {
|
|
18
17
|
return null;
|
|
19
18
|
}
|
|
20
|
-
const {
|
|
19
|
+
const {backgroundColor, textColor, isCloseable} = announcementBar;
|
|
21
20
|
return (
|
|
22
21
|
<div
|
|
23
22
|
className={styles.announcementBar}
|
|
24
23
|
style={{backgroundColor, color: textColor}}
|
|
25
24
|
role="banner">
|
|
26
25
|
{isCloseable && <div className={styles.announcementBarPlaceholder} />}
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// eslint-disable-next-line react/no-danger
|
|
31
|
-
dangerouslySetInnerHTML={{__html: content}}
|
|
32
|
-
/>
|
|
33
|
-
{isCloseable ? (
|
|
34
|
-
<button
|
|
35
|
-
type="button"
|
|
36
|
-
className={clsx('clean-btn close', styles.announcementBarClose)}
|
|
26
|
+
<AnnouncementBarContent className={styles.announcementBarContent} />
|
|
27
|
+
{isCloseable && (
|
|
28
|
+
<AnnouncementBarCloseButton
|
|
37
29
|
onClick={close}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
description: 'The ARIA label for close button of announcement bar',
|
|
42
|
-
})}>
|
|
43
|
-
<IconClose width={14} height={14} strokeWidth={3.1} />
|
|
44
|
-
</button>
|
|
45
|
-
) : null}
|
|
30
|
+
className={styles.announcementBarClose}
|
|
31
|
+
/>
|
|
32
|
+
)}
|
|
46
33
|
</div>
|
|
47
34
|
);
|
|
48
35
|
}
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
height: var(--docusaurus-announcement-bar-height);
|
|
16
16
|
background-color: var(--ifm-color-white);
|
|
17
17
|
color: var(--ifm-color-black);
|
|
18
|
-
|
|
18
|
+
box-shadow: var(--ifm-global-shadow-lw);
|
|
19
|
+
z-index: calc(var(--ifm-z-index-fixed) + 1); /* just above the navbar */
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
html[data-announcement-bar-initially-dismissed='true'] .announcementBar {
|
|
@@ -29,15 +30,10 @@ html[data-announcement-bar-initially-dismissed='true'] .announcementBar {
|
|
|
29
30
|
.announcementBarClose {
|
|
30
31
|
flex: 0 0 30px;
|
|
31
32
|
align-self: stretch;
|
|
32
|
-
padding: 0;
|
|
33
|
-
line-height: 0;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
.announcementBarContent {
|
|
37
36
|
flex: 1 1 auto;
|
|
38
|
-
font-size: 85%;
|
|
39
|
-
text-align: center;
|
|
40
|
-
padding: 5px 0;
|
|
41
37
|
}
|
|
42
38
|
|
|
43
39
|
@media print {
|
|
@@ -46,11 +42,6 @@ html[data-announcement-bar-initially-dismissed='true'] .announcementBar {
|
|
|
46
42
|
}
|
|
47
43
|
}
|
|
48
44
|
|
|
49
|
-
.announcementBarContent a {
|
|
50
|
-
color: inherit;
|
|
51
|
-
text-decoration: underline;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
45
|
@media (min-width: 997px) {
|
|
55
46
|
:root {
|
|
56
47
|
--docusaurus-announcement-bar-height: 30px;
|
|
@@ -6,21 +6,24 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
useCurrentSidebarCategory,
|
|
11
|
+
filterDocCardListItems,
|
|
12
|
+
} from '@docusaurus/theme-common';
|
|
10
13
|
import DocCard from '@theme/DocCard';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return items.
|
|
14
|
-
if (item.type === 'category') {
|
|
15
|
-
return !!findFirstCategoryLink(item);
|
|
16
|
-
}
|
|
17
|
-
return true;
|
|
18
|
-
});
|
|
14
|
+
function DocCardListForCurrentSidebarCategory({className}) {
|
|
15
|
+
const category = useCurrentSidebarCategory();
|
|
16
|
+
return <DocCardList items={category.items} className={className} />;
|
|
19
17
|
}
|
|
20
|
-
export default function DocCardList(
|
|
18
|
+
export default function DocCardList(props) {
|
|
19
|
+
const {items, className} = props;
|
|
20
|
+
if (!items) {
|
|
21
|
+
return <DocCardListForCurrentSidebarCategory {...props} />;
|
|
22
|
+
}
|
|
23
|
+
const filteredItems = filterDocCardListItems(items);
|
|
21
24
|
return (
|
|
22
25
|
<section className={clsx('row', className)}>
|
|
23
|
-
{
|
|
26
|
+
{filteredItems.map((item, index) => (
|
|
24
27
|
<article key={index} className="col col--6 margin-bottom--lg">
|
|
25
28
|
<DocCard item={item} />
|
|
26
29
|
</article>
|
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
HtmlClassNameProvider,
|
|
11
|
+
ThemeClassNames,
|
|
12
|
+
PageMetadata,
|
|
13
|
+
} from '@docusaurus/theme-common';
|
|
10
14
|
import {
|
|
11
15
|
docVersionSearchTag,
|
|
12
16
|
DocsSidebarProvider,
|
|
@@ -16,13 +20,8 @@ import {
|
|
|
16
20
|
import DocPageLayout from '@theme/DocPage/Layout';
|
|
17
21
|
import NotFound from '@theme/NotFound';
|
|
18
22
|
import SearchMetadata from '@theme/SearchMetadata';
|
|
19
|
-
|
|
23
|
+
function DocPageMetadata(props) {
|
|
20
24
|
const {versionMetadata} = props;
|
|
21
|
-
const currentDocRouteMetadata = useDocRouteMetadata(props);
|
|
22
|
-
if (!currentDocRouteMetadata) {
|
|
23
|
-
return <NotFound />;
|
|
24
|
-
}
|
|
25
|
-
const {docElement, sidebarName, sidebarItems} = currentDocRouteMetadata;
|
|
26
25
|
return (
|
|
27
26
|
<>
|
|
28
27
|
<SearchMetadata
|
|
@@ -32,6 +31,24 @@ export default function DocPage(props) {
|
|
|
32
31
|
versionMetadata.version,
|
|
33
32
|
)}
|
|
34
33
|
/>
|
|
34
|
+
<PageMetadata>
|
|
35
|
+
{versionMetadata.noIndex && (
|
|
36
|
+
<meta name="robots" content="noindex, nofollow" />
|
|
37
|
+
)}
|
|
38
|
+
</PageMetadata>
|
|
39
|
+
</>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
export default function DocPage(props) {
|
|
43
|
+
const {versionMetadata} = props;
|
|
44
|
+
const currentDocRouteMetadata = useDocRouteMetadata(props);
|
|
45
|
+
if (!currentDocRouteMetadata) {
|
|
46
|
+
return <NotFound />;
|
|
47
|
+
}
|
|
48
|
+
const {docElement, sidebarName, sidebarItems} = currentDocRouteMetadata;
|
|
49
|
+
return (
|
|
50
|
+
<>
|
|
51
|
+
<DocPageMetadata {...props} />
|
|
35
52
|
<HtmlClassNameProvider
|
|
36
53
|
className={clsx(
|
|
37
54
|
// TODO: it should be removed from here
|
|
@@ -20,7 +20,7 @@ export default function DocSidebarItemLink({
|
|
|
20
20
|
index,
|
|
21
21
|
...props
|
|
22
22
|
}) {
|
|
23
|
-
const {href, label, className} = item;
|
|
23
|
+
const {href, label, className, autoAddBaseUrl} = item;
|
|
24
24
|
const isActive = isActiveSidebarItem(item, activePath);
|
|
25
25
|
const isInternalLink = isInternalUrl(href);
|
|
26
26
|
return (
|
|
@@ -40,6 +40,7 @@ export default function DocSidebarItemLink({
|
|
|
40
40
|
'menu__link--active': isActive,
|
|
41
41
|
},
|
|
42
42
|
)}
|
|
43
|
+
autoAddBaseUrl={autoAddBaseUrl}
|
|
43
44
|
aria-current={isActive ? 'page' : undefined}
|
|
44
45
|
to={href}
|
|
45
46
|
{...(isInternalLink && {
|
|
@@ -5,13 +5,16 @@
|
|
|
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';
|
|
8
|
+
import Translate, {translate} from '@docusaurus/Translate';
|
|
9
9
|
import {useSkipToContent} from '@docusaurus/theme-common/internal';
|
|
10
10
|
import styles from './styles.module.css';
|
|
11
11
|
export default function SkipToContent() {
|
|
12
12
|
const {containerRef, handleSkip} = useSkipToContent();
|
|
13
13
|
return (
|
|
14
|
-
<div
|
|
14
|
+
<div
|
|
15
|
+
ref={containerRef}
|
|
16
|
+
role="region"
|
|
17
|
+
aria-label={translate({id: 'theme.common.skipToMainContent'})}>
|
|
15
18
|
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
16
19
|
<a href="#" className={styles.skipToContent} onClick={handleSkip}>
|
|
17
20
|
<Translate
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@docusaurus/core": "2.
|
|
24
|
-
"@docusaurus/mdx-loader": "2.
|
|
25
|
-
"@docusaurus/module-type-aliases": "2.
|
|
26
|
-
"@docusaurus/plugin-content-blog": "2.
|
|
27
|
-
"@docusaurus/plugin-content-docs": "2.
|
|
28
|
-
"@docusaurus/plugin-content-pages": "2.
|
|
29
|
-
"@docusaurus/theme-common": "2.
|
|
30
|
-
"@docusaurus/theme-translations": "2.
|
|
31
|
-
"@docusaurus/types": "2.
|
|
32
|
-
"@docusaurus/utils": "2.
|
|
33
|
-
"@docusaurus/utils-common": "2.
|
|
34
|
-
"@docusaurus/utils-validation": "2.
|
|
23
|
+
"@docusaurus/core": "2.1.0",
|
|
24
|
+
"@docusaurus/mdx-loader": "2.1.0",
|
|
25
|
+
"@docusaurus/module-type-aliases": "2.1.0",
|
|
26
|
+
"@docusaurus/plugin-content-blog": "2.1.0",
|
|
27
|
+
"@docusaurus/plugin-content-docs": "2.1.0",
|
|
28
|
+
"@docusaurus/plugin-content-pages": "2.1.0",
|
|
29
|
+
"@docusaurus/theme-common": "2.1.0",
|
|
30
|
+
"@docusaurus/theme-translations": "2.1.0",
|
|
31
|
+
"@docusaurus/types": "2.1.0",
|
|
32
|
+
"@docusaurus/utils": "2.1.0",
|
|
33
|
+
"@docusaurus/utils-common": "2.1.0",
|
|
34
|
+
"@docusaurus/utils-validation": "2.1.0",
|
|
35
35
|
"@mdx-js/react": "^1.6.22",
|
|
36
36
|
"clsx": "^1.2.1",
|
|
37
37
|
"copy-text-to-clipboard": "^3.0.1",
|
|
@@ -47,8 +47,6 @@
|
|
|
47
47
|
"utility-types": "^3.10.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@docusaurus/module-type-aliases": "2.0.0-beta.21",
|
|
51
|
-
"@docusaurus/types": "2.0.0-beta.21",
|
|
52
50
|
"@types/mdx-js__react": "^1.5.5",
|
|
53
51
|
"@types/nprogress": "^0.2.0",
|
|
54
52
|
"@types/prismjs": "^1.26.0",
|
|
@@ -64,5 +62,5 @@
|
|
|
64
62
|
"engines": {
|
|
65
63
|
"node": ">=16.14"
|
|
66
64
|
},
|
|
67
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "be9b0942641184213485eba7fd75ceb0b328d3f4"
|
|
68
66
|
}
|
package/src/getSwizzleConfig.ts
CHANGED
|
@@ -28,6 +28,14 @@ export default function getSwizzleConfig(): SwizzleConfig {
|
|
|
28
28
|
description:
|
|
29
29
|
'The color mode toggle to switch between light and dark mode.',
|
|
30
30
|
},
|
|
31
|
+
DocCardList: {
|
|
32
|
+
actions: {
|
|
33
|
+
eject: 'safe',
|
|
34
|
+
wrap: 'safe',
|
|
35
|
+
},
|
|
36
|
+
description:
|
|
37
|
+
'The component responsible for rendering a list of sidebar items cards.\nNotable used on the category generated-index pages.',
|
|
38
|
+
},
|
|
31
39
|
DocSidebar: {
|
|
32
40
|
actions: {
|
|
33
41
|
eject: 'unsafe', // Too much technical code in sidebar, not very safe atm
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import {translate} from '@docusaurus/Translate';
|
|
11
|
+
import IconClose from '@theme/Icon/Close';
|
|
12
|
+
import type {Props} from '@theme/AnnouncementBar/CloseButton';
|
|
13
|
+
import styles from './styles.module.css';
|
|
14
|
+
|
|
15
|
+
export default function AnnouncementBarCloseButton(
|
|
16
|
+
props: Props,
|
|
17
|
+
): JSX.Element | null {
|
|
18
|
+
return (
|
|
19
|
+
<button
|
|
20
|
+
type="button"
|
|
21
|
+
aria-label={translate({
|
|
22
|
+
id: 'theme.AnnouncementBar.closeButtonAriaLabel',
|
|
23
|
+
message: 'Close',
|
|
24
|
+
description: 'The ARIA label for close button of announcement bar',
|
|
25
|
+
})}
|
|
26
|
+
{...props}
|
|
27
|
+
className={clsx('clean-btn close', styles.closeButton, props.className)}>
|
|
28
|
+
<IconClose width={14} height={14} strokeWidth={3.1} />
|
|
29
|
+
</button>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
11
|
+
import type {Props} from '@theme/AnnouncementBar/Content';
|
|
12
|
+
import styles from './styles.module.css';
|
|
13
|
+
|
|
14
|
+
export default function AnnouncementBarContent(
|
|
15
|
+
props: Props,
|
|
16
|
+
): JSX.Element | null {
|
|
17
|
+
const {announcementBar} = useThemeConfig();
|
|
18
|
+
const {content} = announcementBar!;
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
{...props}
|
|
22
|
+
className={clsx(styles.content, props.className)}
|
|
23
|
+
// Developer provided the HTML, so assume it's safe.
|
|
24
|
+
// eslint-disable-next-line react/no-danger
|
|
25
|
+
dangerouslySetInnerHTML={{__html: content}}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
.content {
|
|
9
|
+
font-size: 85%;
|
|
10
|
+
text-align: center;
|
|
11
|
+
padding: 5px 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.content a {
|
|
15
|
+
color: inherit;
|
|
16
|
+
text-decoration: underline;
|
|
17
|
+
}
|
|
@@ -6,49 +6,33 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import clsx from 'clsx';
|
|
10
9
|
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
11
10
|
import {useAnnouncementBar} from '@docusaurus/theme-common/internal';
|
|
12
|
-
import
|
|
13
|
-
import
|
|
11
|
+
import AnnouncementBarCloseButton from '@theme/AnnouncementBar/CloseButton';
|
|
12
|
+
import AnnouncementBarContent from '@theme/AnnouncementBar/Content';
|
|
14
13
|
|
|
15
14
|
import styles from './styles.module.css';
|
|
16
15
|
|
|
17
16
|
export default function AnnouncementBar(): JSX.Element | null {
|
|
18
|
-
const {isActive, close} = useAnnouncementBar();
|
|
19
17
|
const {announcementBar} = useThemeConfig();
|
|
20
|
-
|
|
18
|
+
const {isActive, close} = useAnnouncementBar();
|
|
21
19
|
if (!isActive) {
|
|
22
20
|
return null;
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
const {content, backgroundColor, textColor, isCloseable} = announcementBar!;
|
|
26
|
-
|
|
22
|
+
const {backgroundColor, textColor, isCloseable} = announcementBar!;
|
|
27
23
|
return (
|
|
28
24
|
<div
|
|
29
25
|
className={styles.announcementBar}
|
|
30
26
|
style={{backgroundColor, color: textColor}}
|
|
31
27
|
role="banner">
|
|
32
28
|
{isCloseable && <div className={styles.announcementBarPlaceholder} />}
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// eslint-disable-next-line react/no-danger
|
|
37
|
-
dangerouslySetInnerHTML={{__html: content}}
|
|
38
|
-
/>
|
|
39
|
-
{isCloseable ? (
|
|
40
|
-
<button
|
|
41
|
-
type="button"
|
|
42
|
-
className={clsx('clean-btn close', styles.announcementBarClose)}
|
|
29
|
+
<AnnouncementBarContent className={styles.announcementBarContent} />
|
|
30
|
+
{isCloseable && (
|
|
31
|
+
<AnnouncementBarCloseButton
|
|
43
32
|
onClick={close}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
description: 'The ARIA label for close button of announcement bar',
|
|
48
|
-
})}>
|
|
49
|
-
<IconClose width={14} height={14} strokeWidth={3.1} />
|
|
50
|
-
</button>
|
|
51
|
-
) : null}
|
|
33
|
+
className={styles.announcementBarClose}
|
|
34
|
+
/>
|
|
35
|
+
)}
|
|
52
36
|
</div>
|
|
53
37
|
);
|
|
54
38
|
}
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
height: var(--docusaurus-announcement-bar-height);
|
|
16
16
|
background-color: var(--ifm-color-white);
|
|
17
17
|
color: var(--ifm-color-black);
|
|
18
|
-
|
|
18
|
+
box-shadow: var(--ifm-global-shadow-lw);
|
|
19
|
+
z-index: calc(var(--ifm-z-index-fixed) + 1); /* just above the navbar */
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
html[data-announcement-bar-initially-dismissed='true'] .announcementBar {
|
|
@@ -29,15 +30,10 @@ html[data-announcement-bar-initially-dismissed='true'] .announcementBar {
|
|
|
29
30
|
.announcementBarClose {
|
|
30
31
|
flex: 0 0 30px;
|
|
31
32
|
align-self: stretch;
|
|
32
|
-
padding: 0;
|
|
33
|
-
line-height: 0;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
.announcementBarContent {
|
|
37
36
|
flex: 1 1 auto;
|
|
38
|
-
font-size: 85%;
|
|
39
|
-
text-align: center;
|
|
40
|
-
padding: 5px 0;
|
|
41
37
|
}
|
|
42
38
|
|
|
43
39
|
@media print {
|
|
@@ -46,11 +42,6 @@ html[data-announcement-bar-initially-dismissed='true'] .announcementBar {
|
|
|
46
42
|
}
|
|
47
43
|
}
|
|
48
44
|
|
|
49
|
-
.announcementBarContent a {
|
|
50
|
-
color: inherit;
|
|
51
|
-
text-decoration: underline;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
45
|
@media (min-width: 997px) {
|
|
55
46
|
:root {
|
|
56
47
|
--docusaurus-announcement-bar-height: 30px;
|
|
@@ -7,25 +7,27 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
useCurrentSidebarCategory,
|
|
12
|
+
filterDocCardListItems,
|
|
13
|
+
} from '@docusaurus/theme-common';
|
|
11
14
|
import DocCard from '@theme/DocCard';
|
|
12
15
|
import type {Props} from '@theme/DocCardList';
|
|
13
|
-
import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return items.
|
|
18
|
-
if (item.type === 'category') {
|
|
19
|
-
return !!findFirstCategoryLink(item);
|
|
20
|
-
}
|
|
21
|
-
return true;
|
|
22
|
-
});
|
|
17
|
+
function DocCardListForCurrentSidebarCategory({className}: Props) {
|
|
18
|
+
const category = useCurrentSidebarCategory();
|
|
19
|
+
return <DocCardList items={category.items} className={className} />;
|
|
23
20
|
}
|
|
24
21
|
|
|
25
|
-
export default function DocCardList(
|
|
22
|
+
export default function DocCardList(props: Props): JSX.Element {
|
|
23
|
+
const {items, className} = props;
|
|
24
|
+
if (!items) {
|
|
25
|
+
return <DocCardListForCurrentSidebarCategory {...props} />;
|
|
26
|
+
}
|
|
27
|
+
const filteredItems = filterDocCardListItems(items);
|
|
26
28
|
return (
|
|
27
29
|
<section className={clsx('row', className)}>
|
|
28
|
-
{
|
|
30
|
+
{filteredItems.map((item, index) => (
|
|
29
31
|
<article key={index} className="col col--6 margin-bottom--lg">
|
|
30
32
|
<DocCard item={item} />
|
|
31
33
|
</article>
|
|
@@ -7,7 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
HtmlClassNameProvider,
|
|
12
|
+
ThemeClassNames,
|
|
13
|
+
PageMetadata,
|
|
14
|
+
} from '@docusaurus/theme-common';
|
|
11
15
|
import {
|
|
12
16
|
docVersionSearchTag,
|
|
13
17
|
DocsSidebarProvider,
|
|
@@ -19,13 +23,8 @@ import NotFound from '@theme/NotFound';
|
|
|
19
23
|
import SearchMetadata from '@theme/SearchMetadata';
|
|
20
24
|
import type {Props} from '@theme/DocPage';
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
function DocPageMetadata(props: Props): JSX.Element {
|
|
23
27
|
const {versionMetadata} = props;
|
|
24
|
-
const currentDocRouteMetadata = useDocRouteMetadata(props);
|
|
25
|
-
if (!currentDocRouteMetadata) {
|
|
26
|
-
return <NotFound />;
|
|
27
|
-
}
|
|
28
|
-
const {docElement, sidebarName, sidebarItems} = currentDocRouteMetadata;
|
|
29
28
|
return (
|
|
30
29
|
<>
|
|
31
30
|
<SearchMetadata
|
|
@@ -35,6 +34,25 @@ export default function DocPage(props: Props): JSX.Element {
|
|
|
35
34
|
versionMetadata.version,
|
|
36
35
|
)}
|
|
37
36
|
/>
|
|
37
|
+
<PageMetadata>
|
|
38
|
+
{versionMetadata.noIndex && (
|
|
39
|
+
<meta name="robots" content="noindex, nofollow" />
|
|
40
|
+
)}
|
|
41
|
+
</PageMetadata>
|
|
42
|
+
</>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default function DocPage(props: Props): JSX.Element {
|
|
47
|
+
const {versionMetadata} = props;
|
|
48
|
+
const currentDocRouteMetadata = useDocRouteMetadata(props);
|
|
49
|
+
if (!currentDocRouteMetadata) {
|
|
50
|
+
return <NotFound />;
|
|
51
|
+
}
|
|
52
|
+
const {docElement, sidebarName, sidebarItems} = currentDocRouteMetadata;
|
|
53
|
+
return (
|
|
54
|
+
<>
|
|
55
|
+
<DocPageMetadata {...props} />
|
|
38
56
|
<HtmlClassNameProvider
|
|
39
57
|
className={clsx(
|
|
40
58
|
// TODO: it should be removed from here
|
|
@@ -24,7 +24,7 @@ export default function DocSidebarItemLink({
|
|
|
24
24
|
index,
|
|
25
25
|
...props
|
|
26
26
|
}: Props): JSX.Element {
|
|
27
|
-
const {href, label, className} = item;
|
|
27
|
+
const {href, label, className, autoAddBaseUrl} = item;
|
|
28
28
|
const isActive = isActiveSidebarItem(item, activePath);
|
|
29
29
|
const isInternalLink = isInternalUrl(href);
|
|
30
30
|
return (
|
|
@@ -44,6 +44,7 @@ export default function DocSidebarItemLink({
|
|
|
44
44
|
'menu__link--active': isActive,
|
|
45
45
|
},
|
|
46
46
|
)}
|
|
47
|
+
autoAddBaseUrl={autoAddBaseUrl}
|
|
47
48
|
aria-current={isActive ? 'page' : undefined}
|
|
48
49
|
to={href}
|
|
49
50
|
{...(isInternalLink && {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import Translate from '@docusaurus/Translate';
|
|
9
|
+
import Translate, {translate} from '@docusaurus/Translate';
|
|
10
10
|
import {useSkipToContent} from '@docusaurus/theme-common/internal';
|
|
11
11
|
|
|
12
12
|
import styles from './styles.module.css';
|
|
@@ -14,7 +14,10 @@ import styles from './styles.module.css';
|
|
|
14
14
|
export default function SkipToContent(): JSX.Element {
|
|
15
15
|
const {containerRef, handleSkip} = useSkipToContent();
|
|
16
16
|
return (
|
|
17
|
-
<div
|
|
17
|
+
<div
|
|
18
|
+
ref={containerRef}
|
|
19
|
+
role="region"
|
|
20
|
+
aria-label={translate({id: 'theme.common.skipToMainContent'})}>
|
|
18
21
|
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
19
22
|
<a href="#" className={styles.skipToContent} onClick={handleSkip}>
|
|
20
23
|
<Translate
|
package/src/theme-classic.d.ts
CHANGED
|
@@ -55,6 +55,22 @@ declare module '@theme/AnnouncementBar' {
|
|
|
55
55
|
export default function AnnouncementBar(): JSX.Element | null;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
declare module '@theme/AnnouncementBar/Content' {
|
|
59
|
+
import type {ComponentProps} from 'react';
|
|
60
|
+
|
|
61
|
+
export interface Props extends ComponentProps<'div'> {}
|
|
62
|
+
|
|
63
|
+
export default function AnnouncementBarContent(props: Props): JSX.Element;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare module '@theme/AnnouncementBar/CloseButton' {
|
|
67
|
+
import type {ComponentProps} from 'react';
|
|
68
|
+
|
|
69
|
+
export interface Props extends ComponentProps<'button'> {}
|
|
70
|
+
|
|
71
|
+
export default function AnnouncementBarCloseButton(props: Props): JSX.Element;
|
|
72
|
+
}
|
|
73
|
+
|
|
58
74
|
declare module '@theme/BackToTopButton' {
|
|
59
75
|
export default function BackToTopButton(): JSX.Element;
|
|
60
76
|
}
|
|
@@ -320,7 +336,7 @@ declare module '@theme/DocCardList' {
|
|
|
320
336
|
import type {PropSidebarItem} from '@docusaurus/plugin-content-docs';
|
|
321
337
|
|
|
322
338
|
export interface Props {
|
|
323
|
-
readonly items
|
|
339
|
+
readonly items?: PropSidebarItem[];
|
|
324
340
|
readonly className?: string;
|
|
325
341
|
}
|
|
326
342
|
|