@docusaurus/theme-classic 0.0.0-5145 → 0.0.0-5146
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/Footer/Logo/index.js +3 -1
- package/lib/theme/Logo/index.js +34 -22
- package/lib/validateThemeConfig.js +13 -19
- package/package.json +14 -14
- package/src/theme/Footer/Logo/index.tsx +3 -1
- package/src/theme/Logo/index.tsx +45 -24
- package/src/validateThemeConfig.ts +14 -19
|
@@ -5,6 +5,7 @@
|
|
|
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';
|
|
8
9
|
import Link from '@docusaurus/Link';
|
|
9
10
|
import {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
|
|
10
11
|
import ThemedImage from '@theme/ThemedImage';
|
|
@@ -17,11 +18,12 @@ function LogoImage({logo}) {
|
|
|
17
18
|
};
|
|
18
19
|
return (
|
|
19
20
|
<ThemedImage
|
|
20
|
-
className=
|
|
21
|
+
className={clsx('footer__logo', logo.className)}
|
|
21
22
|
alt={logo.alt}
|
|
22
23
|
sources={sources}
|
|
23
24
|
width={logo.width}
|
|
24
25
|
height={logo.height}
|
|
26
|
+
style={logo.style}
|
|
25
27
|
/>
|
|
26
28
|
);
|
|
27
29
|
}
|
package/lib/theme/Logo/index.js
CHANGED
|
@@ -10,44 +10,56 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
|
10
10
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
11
11
|
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
12
12
|
import ThemedImage from '@theme/ThemedImage';
|
|
13
|
-
|
|
14
|
-
const {
|
|
15
|
-
siteConfig: {title},
|
|
16
|
-
} = useDocusaurusContext();
|
|
17
|
-
const {
|
|
18
|
-
navbar: {title: navbarTitle, logo = {src: ''}},
|
|
19
|
-
} = useThemeConfig();
|
|
20
|
-
const {imageClassName, titleClassName, ...propsRest} = props;
|
|
21
|
-
const logoLink = useBaseUrl(logo.href || '/');
|
|
13
|
+
function LogoThemedImage({logo, alt, imageClassName}) {
|
|
22
14
|
const sources = {
|
|
23
15
|
light: useBaseUrl(logo.src),
|
|
24
16
|
dark: useBaseUrl(logo.srcDark || logo.src),
|
|
25
17
|
};
|
|
26
|
-
// If visible title is shown, fallback alt text should be
|
|
27
|
-
// an empty string to mark the logo as decorative.
|
|
28
|
-
const fallbackAlt = navbarTitle ? '' : title;
|
|
29
|
-
// Use logo alt text if provided (including empty string),
|
|
30
|
-
// and provide a sensible fallback otherwise.
|
|
31
|
-
const alt = logo.alt ?? fallbackAlt;
|
|
32
18
|
const themedImage = (
|
|
33
19
|
<ThemedImage
|
|
20
|
+
className={logo.className}
|
|
34
21
|
sources={sources}
|
|
35
22
|
height={logo.height}
|
|
36
23
|
width={logo.width}
|
|
37
24
|
alt={alt}
|
|
25
|
+
style={logo.style}
|
|
38
26
|
/>
|
|
39
27
|
);
|
|
28
|
+
// Is this extra div really necessary?
|
|
29
|
+
// introduced in https://github.com/facebook/docusaurus/pull/5666
|
|
30
|
+
return imageClassName ? (
|
|
31
|
+
<div className={imageClassName}>{themedImage}</div>
|
|
32
|
+
) : (
|
|
33
|
+
themedImage
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
export default function Logo(props) {
|
|
37
|
+
const {
|
|
38
|
+
siteConfig: {title},
|
|
39
|
+
} = useDocusaurusContext();
|
|
40
|
+
const {
|
|
41
|
+
navbar: {title: navbarTitle, logo},
|
|
42
|
+
} = useThemeConfig();
|
|
43
|
+
const {imageClassName, titleClassName, ...propsRest} = props;
|
|
44
|
+
const logoLink = useBaseUrl(logo?.href || '/');
|
|
45
|
+
// If visible title is shown, fallback alt text should be
|
|
46
|
+
// an empty string to mark the logo as decorative.
|
|
47
|
+
const fallbackAlt = navbarTitle ? '' : title;
|
|
48
|
+
// Use logo alt text if provided (including empty string),
|
|
49
|
+
// and provide a sensible fallback otherwise.
|
|
50
|
+
const alt = logo?.alt ?? fallbackAlt;
|
|
40
51
|
return (
|
|
41
52
|
<Link
|
|
42
53
|
to={logoLink}
|
|
43
54
|
{...propsRest}
|
|
44
|
-
{...(logo
|
|
45
|
-
{logo
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
{...(logo?.target && {target: logo.target})}>
|
|
56
|
+
{logo && (
|
|
57
|
+
<LogoThemedImage
|
|
58
|
+
logo={logo}
|
|
59
|
+
alt={alt}
|
|
60
|
+
imageClassName={imageClassName}
|
|
61
|
+
/>
|
|
62
|
+
)}
|
|
51
63
|
{navbarTitle != null && <b className={titleClassName}>{navbarTitle}</b>}
|
|
52
64
|
</Link>
|
|
53
65
|
);
|
|
@@ -268,6 +268,17 @@ const FooterLinkItemSchema = utils_validation_1.Joi.object({
|
|
|
268
268
|
const CustomCssSchema = utils_validation_1.Joi.alternatives()
|
|
269
269
|
.try(utils_validation_1.Joi.array().items(utils_validation_1.Joi.string().required()), utils_validation_1.Joi.string().required())
|
|
270
270
|
.optional();
|
|
271
|
+
const LogoSchema = utils_validation_1.Joi.object({
|
|
272
|
+
alt: utils_validation_1.Joi.string().allow(''),
|
|
273
|
+
src: utils_validation_1.Joi.string().required(),
|
|
274
|
+
srcDark: utils_validation_1.Joi.string(),
|
|
275
|
+
width: utils_validation_1.Joi.alternatives().try(utils_validation_1.Joi.string(), utils_validation_1.Joi.number()),
|
|
276
|
+
height: utils_validation_1.Joi.alternatives().try(utils_validation_1.Joi.string(), utils_validation_1.Joi.number()),
|
|
277
|
+
href: utils_validation_1.Joi.string(),
|
|
278
|
+
target: utils_validation_1.Joi.string(),
|
|
279
|
+
style: utils_validation_1.Joi.object(),
|
|
280
|
+
className: utils_validation_1.Joi.string(),
|
|
281
|
+
});
|
|
271
282
|
exports.ThemeConfigSchema = utils_validation_1.Joi.object({
|
|
272
283
|
// TODO temporary (@alpha-58)
|
|
273
284
|
// @ts-expect-error: forbidden
|
|
@@ -309,28 +320,11 @@ exports.ThemeConfigSchema = utils_validation_1.Joi.object({
|
|
|
309
320
|
.items(NavbarItemSchema)
|
|
310
321
|
.default(exports.DEFAULT_CONFIG.navbar.items),
|
|
311
322
|
title: utils_validation_1.Joi.string().allow('', null),
|
|
312
|
-
logo:
|
|
313
|
-
alt: utils_validation_1.Joi.string().allow(''),
|
|
314
|
-
src: utils_validation_1.Joi.string().required(),
|
|
315
|
-
srcDark: utils_validation_1.Joi.string(),
|
|
316
|
-
width: utils_validation_1.Joi.alternatives().try(utils_validation_1.Joi.string(), utils_validation_1.Joi.number()),
|
|
317
|
-
height: utils_validation_1.Joi.alternatives().try(utils_validation_1.Joi.string(), utils_validation_1.Joi.number()),
|
|
318
|
-
href: utils_validation_1.Joi.string(),
|
|
319
|
-
target: utils_validation_1.Joi.string(),
|
|
320
|
-
}),
|
|
323
|
+
logo: LogoSchema,
|
|
321
324
|
}).default(exports.DEFAULT_CONFIG.navbar),
|
|
322
325
|
footer: utils_validation_1.Joi.object({
|
|
323
326
|
style: utils_validation_1.Joi.string().equal('dark', 'light').default('light'),
|
|
324
|
-
logo:
|
|
325
|
-
alt: utils_validation_1.Joi.string().allow(''),
|
|
326
|
-
src: utils_validation_1.Joi.string().required(),
|
|
327
|
-
srcDark: utils_validation_1.Joi.string(),
|
|
328
|
-
// TODO infer this from reading the image
|
|
329
|
-
width: utils_validation_1.Joi.alternatives().try(utils_validation_1.Joi.string(), utils_validation_1.Joi.number()),
|
|
330
|
-
height: utils_validation_1.Joi.alternatives().try(utils_validation_1.Joi.string(), utils_validation_1.Joi.number()),
|
|
331
|
-
href: utils_validation_1.Joi.string(),
|
|
332
|
-
target: utils_validation_1.Joi.string(),
|
|
333
|
-
}),
|
|
327
|
+
logo: LogoSchema,
|
|
334
328
|
copyright: utils_validation_1.Joi.string(),
|
|
335
329
|
links: utils_validation_1.Joi.alternatives(utils_validation_1.Joi.array().items(utils_validation_1.Joi.object({
|
|
336
330
|
title: utils_validation_1.Joi.string().allow(null).default(null),
|
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-5146",
|
|
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": "0.0.0-
|
|
24
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
25
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
26
|
-
"@docusaurus/plugin-content-blog": "0.0.0-
|
|
27
|
-
"@docusaurus/plugin-content-docs": "0.0.0-
|
|
28
|
-
"@docusaurus/plugin-content-pages": "0.0.0-
|
|
29
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
30
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
31
|
-
"@docusaurus/types": "0.0.0-
|
|
32
|
-
"@docusaurus/utils": "0.0.0-
|
|
33
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
34
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
23
|
+
"@docusaurus/core": "0.0.0-5146",
|
|
24
|
+
"@docusaurus/mdx-loader": "0.0.0-5146",
|
|
25
|
+
"@docusaurus/module-type-aliases": "0.0.0-5146",
|
|
26
|
+
"@docusaurus/plugin-content-blog": "0.0.0-5146",
|
|
27
|
+
"@docusaurus/plugin-content-docs": "0.0.0-5146",
|
|
28
|
+
"@docusaurus/plugin-content-pages": "0.0.0-5146",
|
|
29
|
+
"@docusaurus/theme-common": "0.0.0-5146",
|
|
30
|
+
"@docusaurus/theme-translations": "0.0.0-5146",
|
|
31
|
+
"@docusaurus/types": "0.0.0-5146",
|
|
32
|
+
"@docusaurus/utils": "0.0.0-5146",
|
|
33
|
+
"@docusaurus/utils-common": "0.0.0-5146",
|
|
34
|
+
"@docusaurus/utils-validation": "0.0.0-5146",
|
|
35
35
|
"@mdx-js/react": "^1.6.22",
|
|
36
36
|
"clsx": "^1.1.1",
|
|
37
37
|
"copy-text-to-clipboard": "^3.0.1",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"engines": {
|
|
65
65
|
"node": ">=16.14"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "7b091c7f5058edd938bfbb3f846822413184c6e0"
|
|
68
68
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
|
+
import clsx from 'clsx';
|
|
9
10
|
import Link from '@docusaurus/Link';
|
|
10
11
|
import {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
|
|
11
12
|
import ThemedImage from '@theme/ThemedImage';
|
|
@@ -21,11 +22,12 @@ function LogoImage({logo}: Props) {
|
|
|
21
22
|
};
|
|
22
23
|
return (
|
|
23
24
|
<ThemedImage
|
|
24
|
-
className=
|
|
25
|
+
className={clsx('footer__logo', logo.className)}
|
|
25
26
|
alt={logo.alt}
|
|
26
27
|
sources={sources}
|
|
27
28
|
width={logo.width}
|
|
28
29
|
height={logo.height}
|
|
30
|
+
style={logo.style}
|
|
29
31
|
/>
|
|
30
32
|
);
|
|
31
33
|
}
|
package/src/theme/Logo/index.tsx
CHANGED
|
@@ -9,24 +9,53 @@ import React from 'react';
|
|
|
9
9
|
import Link from '@docusaurus/Link';
|
|
10
10
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
11
11
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
12
|
-
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
12
|
+
import {useThemeConfig, type NavbarLogo} from '@docusaurus/theme-common';
|
|
13
13
|
import ThemedImage from '@theme/ThemedImage';
|
|
14
14
|
import type {Props} from '@theme/Logo';
|
|
15
15
|
|
|
16
|
+
function LogoThemedImage({
|
|
17
|
+
logo,
|
|
18
|
+
alt,
|
|
19
|
+
imageClassName,
|
|
20
|
+
}: {
|
|
21
|
+
logo: NavbarLogo;
|
|
22
|
+
alt: string;
|
|
23
|
+
imageClassName?: string;
|
|
24
|
+
}) {
|
|
25
|
+
const sources = {
|
|
26
|
+
light: useBaseUrl(logo.src),
|
|
27
|
+
dark: useBaseUrl(logo.srcDark || logo.src),
|
|
28
|
+
};
|
|
29
|
+
const themedImage = (
|
|
30
|
+
<ThemedImage
|
|
31
|
+
className={logo.className}
|
|
32
|
+
sources={sources}
|
|
33
|
+
height={logo.height}
|
|
34
|
+
width={logo.width}
|
|
35
|
+
alt={alt}
|
|
36
|
+
style={logo.style}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
// Is this extra div really necessary?
|
|
41
|
+
// introduced in https://github.com/facebook/docusaurus/pull/5666
|
|
42
|
+
return imageClassName ? (
|
|
43
|
+
<div className={imageClassName}>{themedImage}</div>
|
|
44
|
+
) : (
|
|
45
|
+
themedImage
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
16
49
|
export default function Logo(props: Props): JSX.Element {
|
|
17
50
|
const {
|
|
18
51
|
siteConfig: {title},
|
|
19
52
|
} = useDocusaurusContext();
|
|
20
53
|
const {
|
|
21
|
-
navbar: {title: navbarTitle, logo
|
|
54
|
+
navbar: {title: navbarTitle, logo},
|
|
22
55
|
} = useThemeConfig();
|
|
23
56
|
|
|
24
57
|
const {imageClassName, titleClassName, ...propsRest} = props;
|
|
25
|
-
const logoLink = useBaseUrl(logo
|
|
26
|
-
const sources = {
|
|
27
|
-
light: useBaseUrl(logo.src),
|
|
28
|
-
dark: useBaseUrl(logo.srcDark || logo.src),
|
|
29
|
-
};
|
|
58
|
+
const logoLink = useBaseUrl(logo?.href || '/');
|
|
30
59
|
|
|
31
60
|
// If visible title is shown, fallback alt text should be
|
|
32
61
|
// an empty string to mark the logo as decorative.
|
|
@@ -34,28 +63,20 @@ export default function Logo(props: Props): JSX.Element {
|
|
|
34
63
|
|
|
35
64
|
// Use logo alt text if provided (including empty string),
|
|
36
65
|
// and provide a sensible fallback otherwise.
|
|
37
|
-
const alt = logo
|
|
38
|
-
|
|
39
|
-
const themedImage = (
|
|
40
|
-
<ThemedImage
|
|
41
|
-
sources={sources}
|
|
42
|
-
height={logo.height}
|
|
43
|
-
width={logo.width}
|
|
44
|
-
alt={alt}
|
|
45
|
-
/>
|
|
46
|
-
);
|
|
66
|
+
const alt = logo?.alt ?? fallbackAlt;
|
|
47
67
|
|
|
48
68
|
return (
|
|
49
69
|
<Link
|
|
50
70
|
to={logoLink}
|
|
51
71
|
{...propsRest}
|
|
52
|
-
{...(logo
|
|
53
|
-
{logo
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
72
|
+
{...(logo?.target && {target: logo.target})}>
|
|
73
|
+
{logo && (
|
|
74
|
+
<LogoThemedImage
|
|
75
|
+
logo={logo}
|
|
76
|
+
alt={alt}
|
|
77
|
+
imageClassName={imageClassName}
|
|
78
|
+
/>
|
|
79
|
+
)}
|
|
59
80
|
{navbarTitle != null && <b className={titleClassName}>{navbarTitle}</b>}
|
|
60
81
|
</Link>
|
|
61
82
|
);
|
|
@@ -300,6 +300,18 @@ const CustomCssSchema = Joi.alternatives()
|
|
|
300
300
|
.try(Joi.array().items(Joi.string().required()), Joi.string().required())
|
|
301
301
|
.optional();
|
|
302
302
|
|
|
303
|
+
const LogoSchema = Joi.object({
|
|
304
|
+
alt: Joi.string().allow(''),
|
|
305
|
+
src: Joi.string().required(),
|
|
306
|
+
srcDark: Joi.string(),
|
|
307
|
+
width: Joi.alternatives().try(Joi.string(), Joi.number()),
|
|
308
|
+
height: Joi.alternatives().try(Joi.string(), Joi.number()),
|
|
309
|
+
href: Joi.string(),
|
|
310
|
+
target: Joi.string(),
|
|
311
|
+
style: Joi.object(),
|
|
312
|
+
className: Joi.string(),
|
|
313
|
+
});
|
|
314
|
+
|
|
303
315
|
export const ThemeConfigSchema = Joi.object<ThemeConfig>({
|
|
304
316
|
// TODO temporary (@alpha-58)
|
|
305
317
|
// @ts-expect-error: forbidden
|
|
@@ -344,28 +356,11 @@ export const ThemeConfigSchema = Joi.object<ThemeConfig>({
|
|
|
344
356
|
.items(NavbarItemSchema)
|
|
345
357
|
.default(DEFAULT_CONFIG.navbar.items),
|
|
346
358
|
title: Joi.string().allow('', null),
|
|
347
|
-
logo:
|
|
348
|
-
alt: Joi.string().allow(''),
|
|
349
|
-
src: Joi.string().required(),
|
|
350
|
-
srcDark: Joi.string(),
|
|
351
|
-
width: Joi.alternatives().try(Joi.string(), Joi.number()),
|
|
352
|
-
height: Joi.alternatives().try(Joi.string(), Joi.number()),
|
|
353
|
-
href: Joi.string(),
|
|
354
|
-
target: Joi.string(),
|
|
355
|
-
}),
|
|
359
|
+
logo: LogoSchema,
|
|
356
360
|
}).default(DEFAULT_CONFIG.navbar),
|
|
357
361
|
footer: Joi.object({
|
|
358
362
|
style: Joi.string().equal('dark', 'light').default('light'),
|
|
359
|
-
logo:
|
|
360
|
-
alt: Joi.string().allow(''),
|
|
361
|
-
src: Joi.string().required(),
|
|
362
|
-
srcDark: Joi.string(),
|
|
363
|
-
// TODO infer this from reading the image
|
|
364
|
-
width: Joi.alternatives().try(Joi.string(), Joi.number()),
|
|
365
|
-
height: Joi.alternatives().try(Joi.string(), Joi.number()),
|
|
366
|
-
href: Joi.string(),
|
|
367
|
-
target: Joi.string(),
|
|
368
|
-
}),
|
|
363
|
+
logo: LogoSchema,
|
|
369
364
|
copyright: Joi.string(),
|
|
370
365
|
links: Joi.alternatives(
|
|
371
366
|
Joi.array().items(
|