@docusaurus/theme-classic 2.0.0-beta.1ec2c95e3 → 2.0.0-beta.2
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/theme/DocPage/styles.module.css +6 -0
- package/lib/theme/DocSidebar/index.js +1 -4
- package/lib/theme/DocVersionSuggestions/index.js +111 -0
- package/lib/theme/Footer/index.js +1 -8
- package/lib/theme/SkipToContent/index.js +2 -10
- package/lib/theme/hooks/useAnnouncementBar.js +63 -0
- package/lib-next/theme/DocPage/styles.module.css +6 -0
- package/lib-next/theme/DocSidebar/index.js +1 -2
- package/lib-next/theme/DocVersionSuggestions/index.js +126 -0
- package/lib-next/theme/Footer/index.js +1 -10
- package/lib-next/theme/SkipToContent/index.js +2 -5
- package/lib-next/theme/hooks/useAnnouncementBar.js +49 -0
- package/package.json +12 -12
- package/src/theme/DocPage/styles.module.css +6 -0
- package/src/theme/DocSidebar/index.tsx +1 -2
- package/src/theme/Footer/index.tsx +1 -10
- package/src/theme/SkipToContent/index.tsx +2 -5
|
@@ -137,14 +137,11 @@ function DocSidebarItemCategory({
|
|
|
137
137
|
return <li className={(0, _clsx.default)('menu__list-item', {
|
|
138
138
|
'menu__list-item--collapsed': collapsed
|
|
139
139
|
})}>
|
|
140
|
-
{
|
|
141
|
-
/* eslint-disable-next-line jsx-a11y/anchor-is-valid */
|
|
142
|
-
}
|
|
143
140
|
<a className={(0, _clsx.default)('menu__link', {
|
|
144
141
|
'menu__link--sublist': collapsible,
|
|
145
142
|
'menu__link--active': collapsible && isActive,
|
|
146
143
|
[_stylesModule.default.menuLinkText]: !collapsible
|
|
147
|
-
})} onClick={collapsible ? handleItemClick : undefined} href={collapsible ? '
|
|
144
|
+
})} onClick={collapsible ? handleItemClick : undefined} href={collapsible ? '#!' : undefined} {...props}>
|
|
148
145
|
{label}
|
|
149
146
|
</a>
|
|
150
147
|
<ul className="menu__list" ref={menuListRef} style={{
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _useDocusaurusContext = _interopRequireDefault(require("@docusaurus/useDocusaurusContext"));
|
|
11
|
+
|
|
12
|
+
var _Link = _interopRequireDefault(require("@docusaurus/Link"));
|
|
13
|
+
|
|
14
|
+
var _Translate = _interopRequireDefault(require("@docusaurus/Translate"));
|
|
15
|
+
|
|
16
|
+
var _useDocs = require("@theme/hooks/useDocs");
|
|
17
|
+
|
|
18
|
+
var _themeCommon = require("@docusaurus/theme-common");
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the MIT license found in the
|
|
26
|
+
* LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/
|
|
28
|
+
function UnreleasedVersionLabel({
|
|
29
|
+
siteTitle,
|
|
30
|
+
versionLabel
|
|
31
|
+
}) {
|
|
32
|
+
return <_Translate.default id="theme.docs.versions.unreleasedVersionLabel" description="The label used to tell the user that he's browsing an unreleased doc version" values={{
|
|
33
|
+
siteTitle,
|
|
34
|
+
versionLabel: <b>{versionLabel}</b>
|
|
35
|
+
}}>
|
|
36
|
+
{'This is unreleased documentation for {siteTitle} {versionLabel} version.'}
|
|
37
|
+
</_Translate.default>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function UnmaintainedVersionLabel({
|
|
41
|
+
siteTitle,
|
|
42
|
+
versionLabel
|
|
43
|
+
}) {
|
|
44
|
+
return <_Translate.default id="theme.docs.versions.unmaintainedVersionLabel" description="The label used to tell the user that he's browsing an unmaintained doc version" values={{
|
|
45
|
+
siteTitle,
|
|
46
|
+
versionLabel: <b>{versionLabel}</b>
|
|
47
|
+
}}>
|
|
48
|
+
{'This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained.'}
|
|
49
|
+
</_Translate.default>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function LatestVersionSuggestionLabel({
|
|
53
|
+
versionLabel,
|
|
54
|
+
to,
|
|
55
|
+
onClick
|
|
56
|
+
}) {
|
|
57
|
+
return <_Translate.default id="theme.docs.versions.latestVersionSuggestionLabel" description="The label userd to tell the user that he's browsing an unmaintained doc version" values={{
|
|
58
|
+
versionLabel,
|
|
59
|
+
latestVersionLink: <b>
|
|
60
|
+
<_Link.default to={to} onClick={onClick}>
|
|
61
|
+
<_Translate.default id="theme.docs.versions.latestVersionLinkLabel" description="The label used for the latest version suggestion link label">
|
|
62
|
+
latest version
|
|
63
|
+
</_Translate.default>
|
|
64
|
+
</_Link.default>
|
|
65
|
+
</b>
|
|
66
|
+
}}>
|
|
67
|
+
{'For up-to-date documentation, see the {latestVersionLink} ({versionLabel}).'}
|
|
68
|
+
</_Translate.default>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const getVersionMainDoc = version => version.docs.find(doc => doc.id === version.mainDocId);
|
|
72
|
+
|
|
73
|
+
function DocVersionSuggestions() {
|
|
74
|
+
const {
|
|
75
|
+
siteConfig: {
|
|
76
|
+
title: siteTitle
|
|
77
|
+
}
|
|
78
|
+
} = (0, _useDocusaurusContext.default)();
|
|
79
|
+
const {
|
|
80
|
+
pluginId
|
|
81
|
+
} = (0, _useDocs.useActivePlugin)({
|
|
82
|
+
failfast: true
|
|
83
|
+
});
|
|
84
|
+
const {
|
|
85
|
+
savePreferredVersionName
|
|
86
|
+
} = (0, _themeCommon.useDocsPreferredVersion)(pluginId);
|
|
87
|
+
const activeVersion = (0, _useDocs.useActiveVersion)(pluginId);
|
|
88
|
+
const {
|
|
89
|
+
latestDocSuggestion,
|
|
90
|
+
latestVersionSuggestion
|
|
91
|
+
} = (0, _useDocs.useDocVersionSuggestions)(pluginId); // No suggestion to be made
|
|
92
|
+
|
|
93
|
+
if (!latestVersionSuggestion) {
|
|
94
|
+
return <></>;
|
|
95
|
+
} // try to link to same doc in latest version (not always possible)
|
|
96
|
+
// fallback to main doc of latest version
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
const latestVersionSuggestedDoc = latestDocSuggestion !== null && latestDocSuggestion !== void 0 ? latestDocSuggestion : getVersionMainDoc(latestVersionSuggestion);
|
|
100
|
+
return <div className="alert alert--warning margin-bottom--md" role="alert">
|
|
101
|
+
<div>
|
|
102
|
+
{activeVersion.name === 'current' ? <UnreleasedVersionLabel siteTitle={siteTitle} versionLabel={activeVersion.label} /> : <UnmaintainedVersionLabel siteTitle={siteTitle} versionLabel={activeVersion.label} />}
|
|
103
|
+
</div>
|
|
104
|
+
<div className="margin-top--md">
|
|
105
|
+
<LatestVersionSuggestionLabel versionLabel={latestVersionSuggestion.label} to={latestVersionSuggestedDoc.path} onClick={() => savePreferredVersionName(latestVersionSuggestion.name)} />
|
|
106
|
+
</div>
|
|
107
|
+
</div>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
var _default = DocVersionSuggestions;
|
|
111
|
+
exports.default = _default;
|
|
@@ -15,14 +15,10 @@ var _themeCommon = require("@docusaurus/theme-common");
|
|
|
15
15
|
|
|
16
16
|
var _useBaseUrl = _interopRequireDefault(require("@docusaurus/useBaseUrl"));
|
|
17
17
|
|
|
18
|
-
var _isInternalUrl = _interopRequireDefault(require("@docusaurus/isInternalUrl"));
|
|
19
|
-
|
|
20
18
|
var _stylesModule = _interopRequireDefault(require("./styles.module.css"));
|
|
21
19
|
|
|
22
20
|
var _ThemedImage = _interopRequireDefault(require("@theme/ThemedImage"));
|
|
23
21
|
|
|
24
|
-
var _IconExternalLink = _interopRequireDefault(require("@theme/IconExternalLink"));
|
|
25
|
-
|
|
26
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
23
|
|
|
28
24
|
/**
|
|
@@ -47,10 +43,7 @@ function FooterLink({
|
|
|
47
43
|
} : {
|
|
48
44
|
to: toUrl
|
|
49
45
|
}} {...props}>
|
|
50
|
-
{
|
|
51
|
-
{label}
|
|
52
|
-
<_IconExternalLink.default />
|
|
53
|
-
</span> : label}
|
|
46
|
+
{label}
|
|
54
47
|
</_Link.default>;
|
|
55
48
|
}
|
|
56
49
|
|
|
@@ -7,8 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
-
var _router = require("@docusaurus/router");
|
|
11
|
-
|
|
12
10
|
var _Translate = _interopRequireDefault(require("@docusaurus/Translate"));
|
|
13
11
|
|
|
14
12
|
var _themeCommon = require("@docusaurus/theme-common");
|
|
@@ -35,9 +33,6 @@ function programmaticFocus(el) {
|
|
|
35
33
|
|
|
36
34
|
function SkipToContent() {
|
|
37
35
|
const containerRef = (0, _react.useRef)(null);
|
|
38
|
-
const {
|
|
39
|
-
action
|
|
40
|
-
} = (0, _router.useHistory)();
|
|
41
36
|
|
|
42
37
|
const handleSkip = e => {
|
|
43
38
|
e.preventDefault();
|
|
@@ -51,15 +46,12 @@ function SkipToContent() {
|
|
|
51
46
|
(0, _themeCommon.useLocationChange)(({
|
|
52
47
|
location
|
|
53
48
|
}) => {
|
|
54
|
-
if (containerRef.current && !location.hash
|
|
49
|
+
if (containerRef.current && !location.hash) {
|
|
55
50
|
programmaticFocus(containerRef.current);
|
|
56
51
|
}
|
|
57
52
|
});
|
|
58
53
|
return <div ref={containerRef}>
|
|
59
|
-
{
|
|
60
|
-
/* eslint-disable-next-line jsx-a11y/anchor-is-valid */
|
|
61
|
-
}
|
|
62
|
-
<a href="#" className={_stylesModule.default.skipToContent} onClick={handleSkip}>
|
|
54
|
+
<a href="#main" className={_stylesModule.default.skipToContent} onClick={handleSkip}>
|
|
63
55
|
<_Translate.default id="theme.common.skipToMainContent" description="The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation">
|
|
64
56
|
Skip to main content
|
|
65
57
|
</_Translate.default>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _themeCommon = require("@docusaurus/theme-common");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/
|
|
18
|
+
const DismissStorage = (0, _themeCommon.createStorageSlot)('docusaurus.announcement.dismiss');
|
|
19
|
+
const IdStorage = (0, _themeCommon.createStorageSlot)('docusaurus.announcement.id');
|
|
20
|
+
|
|
21
|
+
const useAnnouncementBar = () => {
|
|
22
|
+
const {
|
|
23
|
+
announcementBar
|
|
24
|
+
} = (0, _themeCommon.useThemeConfig)();
|
|
25
|
+
const [isClosed, setClosed] = (0, _react.useState)(true);
|
|
26
|
+
const handleClose = (0, _react.useCallback)(() => {
|
|
27
|
+
DismissStorage.set('true');
|
|
28
|
+
setClosed(true);
|
|
29
|
+
}, []);
|
|
30
|
+
(0, _react.useEffect)(() => {
|
|
31
|
+
if (!announcementBar) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
id
|
|
37
|
+
} = announcementBar;
|
|
38
|
+
let viewedId = IdStorage.get(); // retrocompatibility due to spelling mistake of default id
|
|
39
|
+
// see https://github.com/facebook/docusaurus/issues/3338
|
|
40
|
+
|
|
41
|
+
if (viewedId === 'annoucement-bar') {
|
|
42
|
+
viewedId = 'announcement-bar';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const isNewAnnouncement = id !== viewedId;
|
|
46
|
+
IdStorage.set(id);
|
|
47
|
+
|
|
48
|
+
if (isNewAnnouncement) {
|
|
49
|
+
DismissStorage.set('false');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (isNewAnnouncement || DismissStorage.get() === 'false') {
|
|
53
|
+
setClosed(false);
|
|
54
|
+
}
|
|
55
|
+
}, []);
|
|
56
|
+
return {
|
|
57
|
+
isAnnouncementBarClosed: isClosed,
|
|
58
|
+
closeAnnouncementBar: handleClose
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
var _default = useAnnouncementBar;
|
|
63
|
+
exports.default = _default;
|
|
@@ -119,7 +119,6 @@ function DocSidebarItemCategory({
|
|
|
119
119
|
className={clsx('menu__list-item', {
|
|
120
120
|
'menu__list-item--collapsed': collapsed,
|
|
121
121
|
})}>
|
|
122
|
-
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
123
122
|
<a
|
|
124
123
|
className={clsx('menu__link', {
|
|
125
124
|
'menu__link--sublist': collapsible,
|
|
@@ -127,7 +126,7 @@ function DocSidebarItemCategory({
|
|
|
127
126
|
[styles.menuLinkText]: !collapsible,
|
|
128
127
|
})}
|
|
129
128
|
onClick={collapsible ? handleItemClick : undefined}
|
|
130
|
-
href={collapsible ? '
|
|
129
|
+
href={collapsible ? '#!' : undefined}
|
|
131
130
|
{...props}>
|
|
132
131
|
{label}
|
|
133
132
|
</a>
|
|
@@ -0,0 +1,126 @@
|
|
|
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 useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
9
|
+
import Link from '@docusaurus/Link';
|
|
10
|
+
import Translate from '@docusaurus/Translate';
|
|
11
|
+
import {
|
|
12
|
+
useActivePlugin,
|
|
13
|
+
useActiveVersion,
|
|
14
|
+
useDocVersionSuggestions,
|
|
15
|
+
} from '@theme/hooks/useDocs';
|
|
16
|
+
import {useDocsPreferredVersion} from '@docusaurus/theme-common';
|
|
17
|
+
|
|
18
|
+
function UnreleasedVersionLabel({siteTitle, versionLabel}) {
|
|
19
|
+
return (
|
|
20
|
+
<Translate
|
|
21
|
+
id="theme.docs.versions.unreleasedVersionLabel"
|
|
22
|
+
description="The label used to tell the user that he's browsing an unreleased doc version"
|
|
23
|
+
values={{
|
|
24
|
+
siteTitle,
|
|
25
|
+
versionLabel: <b>{versionLabel}</b>,
|
|
26
|
+
}}>
|
|
27
|
+
{
|
|
28
|
+
'This is unreleased documentation for {siteTitle} {versionLabel} version.'
|
|
29
|
+
}
|
|
30
|
+
</Translate>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function UnmaintainedVersionLabel({siteTitle, versionLabel}) {
|
|
35
|
+
return (
|
|
36
|
+
<Translate
|
|
37
|
+
id="theme.docs.versions.unmaintainedVersionLabel"
|
|
38
|
+
description="The label used to tell the user that he's browsing an unmaintained doc version"
|
|
39
|
+
values={{
|
|
40
|
+
siteTitle,
|
|
41
|
+
versionLabel: <b>{versionLabel}</b>,
|
|
42
|
+
}}>
|
|
43
|
+
{
|
|
44
|
+
'This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained.'
|
|
45
|
+
}
|
|
46
|
+
</Translate>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function LatestVersionSuggestionLabel({versionLabel, to, onClick}) {
|
|
51
|
+
return (
|
|
52
|
+
<Translate
|
|
53
|
+
id="theme.docs.versions.latestVersionSuggestionLabel"
|
|
54
|
+
description="The label userd to tell the user that he's browsing an unmaintained doc version"
|
|
55
|
+
values={{
|
|
56
|
+
versionLabel,
|
|
57
|
+
latestVersionLink: (
|
|
58
|
+
<b>
|
|
59
|
+
<Link to={to} onClick={onClick}>
|
|
60
|
+
<Translate
|
|
61
|
+
id="theme.docs.versions.latestVersionLinkLabel"
|
|
62
|
+
description="The label used for the latest version suggestion link label">
|
|
63
|
+
latest version
|
|
64
|
+
</Translate>
|
|
65
|
+
</Link>
|
|
66
|
+
</b>
|
|
67
|
+
),
|
|
68
|
+
}}>
|
|
69
|
+
{
|
|
70
|
+
'For up-to-date documentation, see the {latestVersionLink} ({versionLabel}).'
|
|
71
|
+
}
|
|
72
|
+
</Translate>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const getVersionMainDoc = (version) =>
|
|
77
|
+
version.docs.find((doc) => doc.id === version.mainDocId);
|
|
78
|
+
|
|
79
|
+
function DocVersionSuggestions() {
|
|
80
|
+
const {
|
|
81
|
+
siteConfig: {title: siteTitle},
|
|
82
|
+
} = useDocusaurusContext();
|
|
83
|
+
const {pluginId} = useActivePlugin({
|
|
84
|
+
failfast: true,
|
|
85
|
+
});
|
|
86
|
+
const {savePreferredVersionName} = useDocsPreferredVersion(pluginId);
|
|
87
|
+
const activeVersion = useActiveVersion(pluginId);
|
|
88
|
+
const {
|
|
89
|
+
latestDocSuggestion,
|
|
90
|
+
latestVersionSuggestion,
|
|
91
|
+
} = useDocVersionSuggestions(pluginId); // No suggestion to be made
|
|
92
|
+
|
|
93
|
+
if (!latestVersionSuggestion) {
|
|
94
|
+
return <></>;
|
|
95
|
+
} // try to link to same doc in latest version (not always possible)
|
|
96
|
+
// fallback to main doc of latest version
|
|
97
|
+
|
|
98
|
+
const latestVersionSuggestedDoc =
|
|
99
|
+
latestDocSuggestion ?? getVersionMainDoc(latestVersionSuggestion);
|
|
100
|
+
return (
|
|
101
|
+
<div className="alert alert--warning margin-bottom--md" role="alert">
|
|
102
|
+
<div>
|
|
103
|
+
{activeVersion.name === 'current' ? (
|
|
104
|
+
<UnreleasedVersionLabel
|
|
105
|
+
siteTitle={siteTitle}
|
|
106
|
+
versionLabel={activeVersion.label}
|
|
107
|
+
/>
|
|
108
|
+
) : (
|
|
109
|
+
<UnmaintainedVersionLabel
|
|
110
|
+
siteTitle={siteTitle}
|
|
111
|
+
versionLabel={activeVersion.label}
|
|
112
|
+
/>
|
|
113
|
+
)}
|
|
114
|
+
</div>
|
|
115
|
+
<div className="margin-top--md">
|
|
116
|
+
<LatestVersionSuggestionLabel
|
|
117
|
+
versionLabel={latestVersionSuggestion.label}
|
|
118
|
+
to={latestVersionSuggestedDoc.path}
|
|
119
|
+
onClick={() => savePreferredVersionName(latestVersionSuggestion.name)}
|
|
120
|
+
/>
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export default DocVersionSuggestions;
|
|
@@ -9,10 +9,8 @@ import clsx from 'clsx';
|
|
|
9
9
|
import Link from '@docusaurus/Link';
|
|
10
10
|
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
11
11
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
12
|
-
import isInternalUrl from '@docusaurus/isInternalUrl';
|
|
13
12
|
import styles from './styles.module.css';
|
|
14
13
|
import ThemedImage from '@theme/ThemedImage';
|
|
15
|
-
import IconExternalLink from '@theme/IconExternalLink';
|
|
16
14
|
|
|
17
15
|
function FooterLink({to, href, label, prependBaseUrlToHref, ...props}) {
|
|
18
16
|
const toUrl = useBaseUrl(to);
|
|
@@ -30,14 +28,7 @@ function FooterLink({to, href, label, prependBaseUrlToHref, ...props}) {
|
|
|
30
28
|
to: toUrl,
|
|
31
29
|
})}
|
|
32
30
|
{...props}>
|
|
33
|
-
{
|
|
34
|
-
<span>
|
|
35
|
-
{label}
|
|
36
|
-
<IconExternalLink />
|
|
37
|
-
</span>
|
|
38
|
-
) : (
|
|
39
|
-
label
|
|
40
|
-
)}
|
|
31
|
+
{label}
|
|
41
32
|
</Link>
|
|
42
33
|
);
|
|
43
34
|
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React, {useRef} from 'react';
|
|
8
|
-
import {useHistory} from '@docusaurus/router';
|
|
9
8
|
import Translate from '@docusaurus/Translate';
|
|
10
9
|
import {useLocationChange} from '@docusaurus/theme-common';
|
|
11
10
|
import styles from './styles.module.css';
|
|
@@ -18,7 +17,6 @@ function programmaticFocus(el) {
|
|
|
18
17
|
|
|
19
18
|
function SkipToContent() {
|
|
20
19
|
const containerRef = useRef(null);
|
|
21
|
-
const {action} = useHistory();
|
|
22
20
|
|
|
23
21
|
const handleSkip = (e) => {
|
|
24
22
|
e.preventDefault();
|
|
@@ -32,14 +30,13 @@ function SkipToContent() {
|
|
|
32
30
|
};
|
|
33
31
|
|
|
34
32
|
useLocationChange(({location}) => {
|
|
35
|
-
if (containerRef.current && !location.hash
|
|
33
|
+
if (containerRef.current && !location.hash) {
|
|
36
34
|
programmaticFocus(containerRef.current);
|
|
37
35
|
}
|
|
38
36
|
});
|
|
39
37
|
return (
|
|
40
38
|
<div ref={containerRef}>
|
|
41
|
-
|
|
42
|
-
<a href="#" className={styles.skipToContent} onClick={handleSkip}>
|
|
39
|
+
<a href="#main" className={styles.skipToContent} onClick={handleSkip}>
|
|
43
40
|
<Translate
|
|
44
41
|
id="theme.common.skipToMainContent"
|
|
45
42
|
description="The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation">
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import {useState, useEffect, useCallback} from 'react';
|
|
8
|
+
import {useThemeConfig, createStorageSlot} from '@docusaurus/theme-common';
|
|
9
|
+
const DismissStorage = createStorageSlot('docusaurus.announcement.dismiss');
|
|
10
|
+
const IdStorage = createStorageSlot('docusaurus.announcement.id');
|
|
11
|
+
|
|
12
|
+
const useAnnouncementBar = () => {
|
|
13
|
+
const {announcementBar} = useThemeConfig();
|
|
14
|
+
const [isClosed, setClosed] = useState(true);
|
|
15
|
+
const handleClose = useCallback(() => {
|
|
16
|
+
DismissStorage.set('true');
|
|
17
|
+
setClosed(true);
|
|
18
|
+
}, []);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!announcementBar) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const {id} = announcementBar;
|
|
25
|
+
let viewedId = IdStorage.get(); // retrocompatibility due to spelling mistake of default id
|
|
26
|
+
// see https://github.com/facebook/docusaurus/issues/3338
|
|
27
|
+
|
|
28
|
+
if (viewedId === 'annoucement-bar') {
|
|
29
|
+
viewedId = 'announcement-bar';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const isNewAnnouncement = id !== viewedId;
|
|
33
|
+
IdStorage.set(id);
|
|
34
|
+
|
|
35
|
+
if (isNewAnnouncement) {
|
|
36
|
+
DismissStorage.set('false');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (isNewAnnouncement || DismissStorage.get() === 'false') {
|
|
40
|
+
setClosed(false);
|
|
41
|
+
}
|
|
42
|
+
}, []);
|
|
43
|
+
return {
|
|
44
|
+
isAnnouncementBarClosed: isClosed,
|
|
45
|
+
closeAnnouncementBar: handleClose,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default useAnnouncementBar;
|
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.2",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/types.d.ts",
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
"update-code-translations": "node -e 'require(\"./update-code-translations.js\").run()'"
|
|
24
24
|
},
|
|
25
25
|
"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/types": "2.0.0-beta.
|
|
32
|
-
"@docusaurus/utils": "2.0.0-beta.
|
|
33
|
-
"@docusaurus/utils-common": "2.0.0-beta.
|
|
34
|
-
"@docusaurus/utils-validation": "2.0.0-beta.
|
|
26
|
+
"@docusaurus/core": "2.0.0-beta.2",
|
|
27
|
+
"@docusaurus/plugin-content-blog": "2.0.0-beta.2",
|
|
28
|
+
"@docusaurus/plugin-content-docs": "2.0.0-beta.2",
|
|
29
|
+
"@docusaurus/plugin-content-pages": "2.0.0-beta.2",
|
|
30
|
+
"@docusaurus/theme-common": "2.0.0-beta.2",
|
|
31
|
+
"@docusaurus/types": "2.0.0-beta.2",
|
|
32
|
+
"@docusaurus/utils": "2.0.0-beta.2",
|
|
33
|
+
"@docusaurus/utils-common": "2.0.0-beta.2",
|
|
34
|
+
"@docusaurus/utils-validation": "2.0.0-beta.2",
|
|
35
35
|
"@mdx-js/mdx": "^1.6.21",
|
|
36
36
|
"@mdx-js/react": "^1.6.21",
|
|
37
37
|
"chalk": "^4.1.1",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"rtlcss": "^3.1.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@docusaurus/module-type-aliases": "2.0.0-beta.
|
|
53
|
+
"@docusaurus/module-type-aliases": "2.0.0-beta.2"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"react": "^16.8.4 || ^17.0.0",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=12.13.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "883f07fddffaf1657407c8e202e370cc436e25f7"
|
|
63
63
|
}
|
|
@@ -128,7 +128,6 @@ function DocSidebarItemCategory({
|
|
|
128
128
|
className={clsx('menu__list-item', {
|
|
129
129
|
'menu__list-item--collapsed': collapsed,
|
|
130
130
|
})}>
|
|
131
|
-
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
132
131
|
<a
|
|
133
132
|
className={clsx('menu__link', {
|
|
134
133
|
'menu__link--sublist': collapsible,
|
|
@@ -136,7 +135,7 @@ function DocSidebarItemCategory({
|
|
|
136
135
|
[styles.menuLinkText]: !collapsible,
|
|
137
136
|
})}
|
|
138
137
|
onClick={collapsible ? handleItemClick : undefined}
|
|
139
|
-
href={collapsible ? '
|
|
138
|
+
href={collapsible ? '#!' : undefined}
|
|
140
139
|
{...props}>
|
|
141
140
|
{label}
|
|
142
141
|
</a>
|
|
@@ -11,10 +11,8 @@ import clsx from 'clsx';
|
|
|
11
11
|
import Link from '@docusaurus/Link';
|
|
12
12
|
import {FooterLinkItem, useThemeConfig} from '@docusaurus/theme-common';
|
|
13
13
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
14
|
-
import isInternalUrl from '@docusaurus/isInternalUrl';
|
|
15
14
|
import styles from './styles.module.css';
|
|
16
15
|
import ThemedImage, {Props as ThemedImageProps} from '@theme/ThemedImage';
|
|
17
|
-
import IconExternalLink from '@theme/IconExternalLink';
|
|
18
16
|
|
|
19
17
|
function FooterLink({
|
|
20
18
|
to,
|
|
@@ -37,14 +35,7 @@ function FooterLink({
|
|
|
37
35
|
to: toUrl,
|
|
38
36
|
})}
|
|
39
37
|
{...props}>
|
|
40
|
-
{
|
|
41
|
-
<span>
|
|
42
|
-
{label}
|
|
43
|
-
<IconExternalLink />
|
|
44
|
-
</span>
|
|
45
|
-
) : (
|
|
46
|
-
label
|
|
47
|
-
)}
|
|
38
|
+
{label}
|
|
48
39
|
</Link>
|
|
49
40
|
);
|
|
50
41
|
}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React, {useRef} from 'react';
|
|
9
|
-
import {useHistory} from '@docusaurus/router';
|
|
10
9
|
import Translate from '@docusaurus/Translate';
|
|
11
10
|
import {useLocationChange} from '@docusaurus/theme-common';
|
|
12
11
|
|
|
@@ -20,7 +19,6 @@ function programmaticFocus(el: HTMLElement) {
|
|
|
20
19
|
|
|
21
20
|
function SkipToContent(): JSX.Element {
|
|
22
21
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
23
|
-
const {action} = useHistory();
|
|
24
22
|
const handleSkip = (e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
25
23
|
e.preventDefault();
|
|
26
24
|
|
|
@@ -34,15 +32,14 @@ function SkipToContent(): JSX.Element {
|
|
|
34
32
|
};
|
|
35
33
|
|
|
36
34
|
useLocationChange(({location}) => {
|
|
37
|
-
if (containerRef.current && !location.hash
|
|
35
|
+
if (containerRef.current && !location.hash) {
|
|
38
36
|
programmaticFocus(containerRef.current);
|
|
39
37
|
}
|
|
40
38
|
});
|
|
41
39
|
|
|
42
40
|
return (
|
|
43
41
|
<div ref={containerRef}>
|
|
44
|
-
|
|
45
|
-
<a href="#" className={styles.skipToContent} onClick={handleSkip}>
|
|
42
|
+
<a href="#main" className={styles.skipToContent} onClick={handleSkip}>
|
|
46
43
|
<Translate
|
|
47
44
|
id="theme.common.skipToMainContent"
|
|
48
45
|
description="The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation">
|