@docusaurus/theme-classic 0.0.0-4875 → 0.0.0-4879
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 +2 -2
- package/lib/theme-classic.d.ts +2 -2
- package/lib/validateThemeConfig.js +2 -3
- package/lib-next/theme/DocSidebarItem/Category.js +2 -2
- package/lib-next/theme/DocSidebarItems/index.js +1 -6
- package/lib-next/theme/DocVersionBanner/index.js +2 -2
- package/lib-next/theme/Heading/index.js +4 -20
- package/lib-next/theme/Layout/index.js +1 -1
- package/lib-next/theme/SiteMetadata/index.js +8 -7
- package/package.json +15 -15
- package/src/getSwizzleConfig.ts +2 -2
- package/src/theme/DocSidebarItem/Category.tsx +2 -2
- package/src/theme/DocSidebarItems/index.tsx +1 -6
- package/src/theme/DocVersionBanner/index.tsx +2 -2
- package/src/theme/Heading/index.tsx +4 -18
- package/src/theme/Layout/index.tsx +1 -1
- package/src/theme/SiteMetadata/index.tsx +8 -8
- package/src/theme-classic.d.ts +2 -2
- package/src/validateThemeConfig.ts +1 -2
package/lib/getSwizzleConfig.js
CHANGED
|
@@ -33,7 +33,7 @@ function getSwizzleConfig() {
|
|
|
33
33
|
DocSidebar: {
|
|
34
34
|
actions: {
|
|
35
35
|
eject: 'unsafe',
|
|
36
|
-
//
|
|
36
|
+
// Too much technical code in sidebar, not very safe atm
|
|
37
37
|
wrap: 'safe'
|
|
38
38
|
},
|
|
39
39
|
description: 'The sidebar component on docs pages'
|
|
@@ -226,7 +226,7 @@ function getSwizzleConfig() {
|
|
|
226
226
|
'prism-include-languages': {
|
|
227
227
|
actions: {
|
|
228
228
|
eject: 'safe',
|
|
229
|
-
wrap: 'forbidden' //
|
|
229
|
+
wrap: 'forbidden' // Not a component!
|
|
230
230
|
|
|
231
231
|
},
|
|
232
232
|
description: 'The Prism languages to include for code block syntax highlighting. Meant to be ejected.'
|
package/lib/theme-classic.d.ts
CHANGED
|
@@ -1022,8 +1022,8 @@ declare module '@theme/TOCItems' {
|
|
|
1022
1022
|
declare module '@theme/TOC' {
|
|
1023
1023
|
import type {TOCItem} from '@docusaurus/types';
|
|
1024
1024
|
|
|
1025
|
-
// minHeadingLevel only
|
|
1026
|
-
// set by Joi. See TOC, TOCInline, TOCCollapsible for examples
|
|
1025
|
+
// `minHeadingLevel` only comes from doc/post front matter, and won't have a
|
|
1026
|
+
// default set by Joi. See TOC, TOCInline, TOCCollapsible for examples.
|
|
1027
1027
|
export interface Props {
|
|
1028
1028
|
readonly toc: readonly TOCItem[];
|
|
1029
1029
|
readonly minHeadingLevel?: number;
|
|
@@ -98,7 +98,7 @@ const HtmlNavbarItemSchema = _utilsValidation.Joi.object({
|
|
|
98
98
|
});
|
|
99
99
|
|
|
100
100
|
const itemWithType = type => {
|
|
101
|
-
//
|
|
101
|
+
// Because equal(undefined) is not supported :/
|
|
102
102
|
const typeSchema = type ? _utilsValidation.Joi.string().required().equal(type) : _utilsValidation.Joi.string().forbidden();
|
|
103
103
|
return _utilsValidation.Joi.object({
|
|
104
104
|
type: typeSchema
|
|
@@ -204,8 +204,7 @@ const ColorModeSchema = _utilsValidation.Joi.object({
|
|
|
204
204
|
switchConfig: _utilsValidation.Joi.any().forbidden().messages({
|
|
205
205
|
'any.unknown': 'colorMode.switchConfig is deprecated. If you want to customize the icons for light and dark mode, swizzle IconLightMode, IconDarkMode, or ColorModeToggle instead.'
|
|
206
206
|
})
|
|
207
|
-
}).default(DEFAULT_COLOR_MODE_CONFIG);
|
|
208
|
-
|
|
207
|
+
}).default(DEFAULT_COLOR_MODE_CONFIG);
|
|
209
208
|
|
|
210
209
|
const HtmlMetadataSchema = _utilsValidation.Joi.object({
|
|
211
210
|
id: _utilsValidation.Joi.string(),
|
|
@@ -92,8 +92,8 @@ export default function DocSidebarItemCategory({
|
|
|
92
92
|
const isActive = isActiveSidebarItem(item, activePath);
|
|
93
93
|
const isCurrentPage = isSamePath(href, activePath);
|
|
94
94
|
const {collapsed, setCollapsed} = useCollapsible({
|
|
95
|
-
//
|
|
96
|
-
//
|
|
95
|
+
// Active categories are always initialized as expanded. The default
|
|
96
|
+
// (`item.collapsed`) is only used for non-active categories.
|
|
97
97
|
initialState: () => {
|
|
98
98
|
if (!collapsible) {
|
|
99
99
|
return false;
|
|
@@ -14,12 +14,7 @@ function DocSidebarItems({items, ...props}) {
|
|
|
14
14
|
return (
|
|
15
15
|
<DocSidebarItemsExpandedStateProvider>
|
|
16
16
|
{items.map((item, index) => (
|
|
17
|
-
<DocSidebarItem
|
|
18
|
-
key={index} // sidebar is static, the index does not change
|
|
19
|
-
item={item}
|
|
20
|
-
index={index}
|
|
21
|
-
{...props}
|
|
22
|
-
/>
|
|
17
|
+
<DocSidebarItem key={index} item={item} index={index} {...props} />
|
|
23
18
|
))}
|
|
24
19
|
</DocSidebarItemsExpandedStateProvider>
|
|
25
20
|
);
|
|
@@ -101,8 +101,8 @@ function DocVersionBannerEnabled({className, versionMetadata}) {
|
|
|
101
101
|
|
|
102
102
|
const {savePreferredVersionName} = useDocsPreferredVersion(pluginId);
|
|
103
103
|
const {latestDocSuggestion, latestVersionSuggestion} =
|
|
104
|
-
useDocVersionSuggestions(pluginId); //
|
|
105
|
-
//
|
|
104
|
+
useDocVersionSuggestions(pluginId); // Try to link to same doc in latest version (not always possible), falling
|
|
105
|
+
// back to main doc of latest version
|
|
106
106
|
|
|
107
107
|
const latestVersionSuggestedDoc =
|
|
108
108
|
latestDocSuggestion ?? getVersionMainDoc(latestVersionSuggestion);
|
|
@@ -9,14 +9,13 @@ import clsx from 'clsx';
|
|
|
9
9
|
import {translate} from '@docusaurus/Translate';
|
|
10
10
|
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
11
11
|
import styles from './styles.module.css';
|
|
12
|
-
|
|
13
|
-
function AnchorHeading({as: As, id, ...props}) {
|
|
12
|
+
export default function Heading({as: As, id, ...props}) {
|
|
14
13
|
const {
|
|
15
14
|
navbar: {hideOnScroll},
|
|
16
|
-
} = useThemeConfig();
|
|
15
|
+
} = useThemeConfig(); // H1 headings do not need an id because they don't appear in the TOC.
|
|
17
16
|
|
|
18
|
-
if (!id) {
|
|
19
|
-
return <As {...props} />;
|
|
17
|
+
if (As === 'h1' || !id) {
|
|
18
|
+
return <As {...props} id={undefined} />;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
return (
|
|
@@ -43,18 +42,3 @@ function AnchorHeading({as: As, id, ...props}) {
|
|
|
43
42
|
</As>
|
|
44
43
|
);
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
export default function Heading({as, ...props}) {
|
|
48
|
-
if (as === 'h1') {
|
|
49
|
-
return (
|
|
50
|
-
<h1
|
|
51
|
-
{...props}
|
|
52
|
-
id={undefined} // h1 headings do not need an id because they don't appear in the TOC
|
|
53
|
-
>
|
|
54
|
-
{props.children}
|
|
55
|
-
</h1>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return <AnchorHeading as={as} {...props} />;
|
|
60
|
-
}
|
|
@@ -24,7 +24,7 @@ export default function Layout(props) {
|
|
|
24
24
|
children,
|
|
25
25
|
noFooter,
|
|
26
26
|
wrapperClassName,
|
|
27
|
-
//
|
|
27
|
+
// Not really layout-related, but kept for convenience/retro-compatibility
|
|
28
28
|
title,
|
|
29
29
|
description,
|
|
30
30
|
} = props;
|
|
@@ -101,15 +101,16 @@ export default function SiteMetadata() {
|
|
|
101
101
|
|
|
102
102
|
<SearchMetadata tag={DEFAULT_SEARCH_TAG} locale={currentLocale} />
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
{/*
|
|
105
|
+
It's important to have an additional <Head> element here, as it allows
|
|
106
|
+
react-helmet to override default metadata values set in previous <Head>
|
|
107
|
+
like "twitter:card". In same Head, the same meta would appear twice
|
|
108
|
+
instead of overriding.
|
|
109
|
+
*/}
|
|
110
|
+
<Head>
|
|
110
111
|
{/* Yes, "metadatum" is the grammatically correct term */}
|
|
111
112
|
{metadata.map((metadatum, i) => (
|
|
112
|
-
<meta key={
|
|
113
|
+
<meta key={i} {...metadatum} />
|
|
113
114
|
))}
|
|
114
115
|
</Head>
|
|
115
116
|
</>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4879",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"format:lib-next": "prettier --config ../../.prettierrc --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@docusaurus/core": "0.0.0-
|
|
25
|
-
"@docusaurus/plugin-content-blog": "0.0.0-
|
|
26
|
-
"@docusaurus/plugin-content-docs": "0.0.0-
|
|
27
|
-
"@docusaurus/plugin-content-pages": "0.0.0-
|
|
28
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
29
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
30
|
-
"@docusaurus/utils": "0.0.0-
|
|
31
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
32
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
24
|
+
"@docusaurus/core": "0.0.0-4879",
|
|
25
|
+
"@docusaurus/plugin-content-blog": "0.0.0-4879",
|
|
26
|
+
"@docusaurus/plugin-content-docs": "0.0.0-4879",
|
|
27
|
+
"@docusaurus/plugin-content-pages": "0.0.0-4879",
|
|
28
|
+
"@docusaurus/theme-common": "0.0.0-4879",
|
|
29
|
+
"@docusaurus/theme-translations": "0.0.0-4879",
|
|
30
|
+
"@docusaurus/utils": "0.0.0-4879",
|
|
31
|
+
"@docusaurus/utils-common": "0.0.0-4879",
|
|
32
|
+
"@docusaurus/utils-validation": "0.0.0-4879",
|
|
33
33
|
"@mdx-js/react": "^1.6.22",
|
|
34
34
|
"clsx": "^1.1.1",
|
|
35
35
|
"copy-text-to-clipboard": "^3.0.1",
|
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
"@babel/cli": "^7.17.6",
|
|
46
46
|
"@babel/core": "^7.17.9",
|
|
47
47
|
"@babel/preset-typescript": "^7.16.7",
|
|
48
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
49
|
-
"@docusaurus/types": "0.0.0-
|
|
48
|
+
"@docusaurus/module-type-aliases": "0.0.0-4879",
|
|
49
|
+
"@docusaurus/types": "0.0.0-4879",
|
|
50
50
|
"@types/mdx-js__react": "^1.5.5",
|
|
51
51
|
"@types/prismjs": "^1.26.0",
|
|
52
|
-
"@types/rtlcss": "^3.1.
|
|
52
|
+
"@types/rtlcss": "^3.1.4",
|
|
53
53
|
"cross-env": "^7.0.3",
|
|
54
|
-
"fs-extra": "^10.0
|
|
54
|
+
"fs-extra": "^10.1.0",
|
|
55
55
|
"react-test-renderer": "^17.0.2",
|
|
56
56
|
"utility-types": "^3.10.0"
|
|
57
57
|
},
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=14"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "0ebf7473396171d10b7c91bc3f33cdf16863ee5c"
|
|
66
66
|
}
|
package/src/getSwizzleConfig.ts
CHANGED
|
@@ -30,7 +30,7 @@ export default function getSwizzleConfig(): SwizzleConfig {
|
|
|
30
30
|
},
|
|
31
31
|
DocSidebar: {
|
|
32
32
|
actions: {
|
|
33
|
-
eject: 'unsafe', //
|
|
33
|
+
eject: 'unsafe', // Too much technical code in sidebar, not very safe atm
|
|
34
34
|
wrap: 'safe',
|
|
35
35
|
},
|
|
36
36
|
description: 'The sidebar component on docs pages',
|
|
@@ -234,7 +234,7 @@ export default function getSwizzleConfig(): SwizzleConfig {
|
|
|
234
234
|
'prism-include-languages': {
|
|
235
235
|
actions: {
|
|
236
236
|
eject: 'safe',
|
|
237
|
-
wrap: 'forbidden', //
|
|
237
|
+
wrap: 'forbidden', // Not a component!
|
|
238
238
|
},
|
|
239
239
|
description:
|
|
240
240
|
'The Prism languages to include for code block syntax highlighting. Meant to be ejected.',
|
|
@@ -111,8 +111,8 @@ export default function DocSidebarItemCategory({
|
|
|
111
111
|
const isCurrentPage = isSamePath(href, activePath);
|
|
112
112
|
|
|
113
113
|
const {collapsed, setCollapsed} = useCollapsible({
|
|
114
|
-
//
|
|
115
|
-
//
|
|
114
|
+
// Active categories are always initialized as expanded. The default
|
|
115
|
+
// (`item.collapsed`) is only used for non-active categories.
|
|
116
116
|
initialState: () => {
|
|
117
117
|
if (!collapsible) {
|
|
118
118
|
return false;
|
|
@@ -17,12 +17,7 @@ function DocSidebarItems({items, ...props}: Props): JSX.Element {
|
|
|
17
17
|
return (
|
|
18
18
|
<DocSidebarItemsExpandedStateProvider>
|
|
19
19
|
{items.map((item, index) => (
|
|
20
|
-
<DocSidebarItem
|
|
21
|
-
key={index} // sidebar is static, the index does not change
|
|
22
|
-
item={item}
|
|
23
|
-
index={index}
|
|
24
|
-
{...props}
|
|
25
|
-
/>
|
|
20
|
+
<DocSidebarItem key={index} item={item} index={index} {...props} />
|
|
26
21
|
))}
|
|
27
22
|
</DocSidebarItemsExpandedStateProvider>
|
|
28
23
|
);
|
|
@@ -136,8 +136,8 @@ function DocVersionBannerEnabled({
|
|
|
136
136
|
const {latestDocSuggestion, latestVersionSuggestion} =
|
|
137
137
|
useDocVersionSuggestions(pluginId);
|
|
138
138
|
|
|
139
|
-
//
|
|
140
|
-
//
|
|
139
|
+
// Try to link to same doc in latest version (not always possible), falling
|
|
140
|
+
// back to main doc of latest version
|
|
141
141
|
const latestVersionSuggestedDoc =
|
|
142
142
|
latestDocSuggestion ?? getVersionMainDoc(latestVersionSuggestion);
|
|
143
143
|
|
|
@@ -13,13 +13,13 @@ import {useThemeConfig} from '@docusaurus/theme-common';
|
|
|
13
13
|
|
|
14
14
|
import styles from './styles.module.css';
|
|
15
15
|
|
|
16
|
-
function
|
|
16
|
+
export default function Heading({as: As, id, ...props}: Props): JSX.Element {
|
|
17
17
|
const {
|
|
18
18
|
navbar: {hideOnScroll},
|
|
19
19
|
} = useThemeConfig();
|
|
20
|
-
|
|
21
|
-
if (!id) {
|
|
22
|
-
return <As {...props} />;
|
|
20
|
+
// H1 headings do not need an id because they don't appear in the TOC.
|
|
21
|
+
if (As === 'h1' || !id) {
|
|
22
|
+
return <As {...props} id={undefined} />;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
return (
|
|
@@ -46,17 +46,3 @@ function AnchorHeading({as: As, id, ...props}: Props) {
|
|
|
46
46
|
</As>
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
export default function Heading({as, ...props}: Props): JSX.Element {
|
|
51
|
-
if (as === 'h1') {
|
|
52
|
-
return (
|
|
53
|
-
<h1
|
|
54
|
-
{...props}
|
|
55
|
-
id={undefined} // h1 headings do not need an id because they don't appear in the TOC
|
|
56
|
-
>
|
|
57
|
-
{props.children}
|
|
58
|
-
</h1>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
return <AnchorHeading as={as} {...props} />;
|
|
62
|
-
}
|
|
@@ -27,7 +27,7 @@ export default function Layout(props: Props): JSX.Element {
|
|
|
27
27
|
children,
|
|
28
28
|
noFooter,
|
|
29
29
|
wrapperClassName,
|
|
30
|
-
//
|
|
30
|
+
// Not really layout-related, but kept for convenience/retro-compatibility
|
|
31
31
|
title,
|
|
32
32
|
description,
|
|
33
33
|
} = props;
|
|
@@ -109,16 +109,16 @@ export default function SiteMetadata(): JSX.Element {
|
|
|
109
109
|
|
|
110
110
|
<SearchMetadata tag={DEFAULT_SEARCH_TAG} locale={currentLocale} />
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
>
|
|
112
|
+
{/*
|
|
113
|
+
It's important to have an additional <Head> element here, as it allows
|
|
114
|
+
react-helmet to override default metadata values set in previous <Head>
|
|
115
|
+
like "twitter:card". In same Head, the same meta would appear twice
|
|
116
|
+
instead of overriding.
|
|
117
|
+
*/}
|
|
118
|
+
<Head>
|
|
119
119
|
{/* Yes, "metadatum" is the grammatically correct term */}
|
|
120
120
|
{metadata.map((metadatum, i) => (
|
|
121
|
-
<meta key={
|
|
121
|
+
<meta key={i} {...metadatum} />
|
|
122
122
|
))}
|
|
123
123
|
</Head>
|
|
124
124
|
</>
|
package/src/theme-classic.d.ts
CHANGED
|
@@ -1022,8 +1022,8 @@ declare module '@theme/TOCItems' {
|
|
|
1022
1022
|
declare module '@theme/TOC' {
|
|
1023
1023
|
import type {TOCItem} from '@docusaurus/types';
|
|
1024
1024
|
|
|
1025
|
-
// minHeadingLevel only
|
|
1026
|
-
// set by Joi. See TOC, TOCInline, TOCCollapsible for examples
|
|
1025
|
+
// `minHeadingLevel` only comes from doc/post front matter, and won't have a
|
|
1026
|
+
// default set by Joi. See TOC, TOCInline, TOCCollapsible for examples.
|
|
1027
1027
|
export interface Props {
|
|
1028
1028
|
readonly toc: readonly TOCItem[];
|
|
1029
1029
|
readonly minHeadingLevel?: number;
|
|
@@ -100,7 +100,7 @@ const HtmlNavbarItemSchema = Joi.object({
|
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
const itemWithType = (type: string | undefined) => {
|
|
103
|
-
//
|
|
103
|
+
// Because equal(undefined) is not supported :/
|
|
104
104
|
const typeSchema = type
|
|
105
105
|
? Joi.string().required().equal(type)
|
|
106
106
|
: Joi.string().forbidden();
|
|
@@ -241,7 +241,6 @@ const ColorModeSchema = Joi.object({
|
|
|
241
241
|
}),
|
|
242
242
|
}).default(DEFAULT_COLOR_MODE_CONFIG);
|
|
243
243
|
|
|
244
|
-
// schema can probably be improved
|
|
245
244
|
const HtmlMetadataSchema = Joi.object({
|
|
246
245
|
id: Joi.string(),
|
|
247
246
|
name: Joi.string(),
|