@docusaurus/theme-classic 0.0.0-5093 → 0.0.0-5097

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.
@@ -6,6 +6,8 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import clsx from 'clsx';
9
+ import {ThemeClassNames} from '@docusaurus/theme-common';
10
+ import Translate from '@docusaurus/Translate';
9
11
  import styles from './styles.module.css';
10
12
  function NoteIcon() {
11
13
  return (
@@ -57,38 +59,75 @@ function CautionIcon() {
57
59
  </svg>
58
60
  );
59
61
  }
62
+ // eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
60
63
  const AdmonitionConfigs = {
61
64
  note: {
62
65
  infimaClassName: 'secondary',
63
66
  iconComponent: NoteIcon,
67
+ label: (
68
+ <Translate
69
+ id="theme.admonition.note"
70
+ description="The default label used for the Note admonition (:::note)">
71
+ note
72
+ </Translate>
73
+ ),
64
74
  },
65
75
  tip: {
66
76
  infimaClassName: 'success',
67
77
  iconComponent: TipIcon,
78
+ label: (
79
+ <Translate
80
+ id="theme.admonition.tip"
81
+ description="The default label used for the Tip admonition (:::tip)">
82
+ tip
83
+ </Translate>
84
+ ),
68
85
  },
69
86
  danger: {
70
87
  infimaClassName: 'danger',
71
88
  iconComponent: DangerIcon,
89
+ label: (
90
+ <Translate
91
+ id="theme.admonition.danger"
92
+ description="The default label used for the Danger admonition (:::danger)">
93
+ danger
94
+ </Translate>
95
+ ),
72
96
  },
73
97
  info: {
74
98
  infimaClassName: 'info',
75
99
  iconComponent: InfoIcon,
100
+ label: (
101
+ <Translate
102
+ id="theme.admonition.info"
103
+ description="The default label used for the Info admonition (:::info)">
104
+ info
105
+ </Translate>
106
+ ),
76
107
  },
77
108
  caution: {
78
109
  infimaClassName: 'warning',
79
110
  iconComponent: CautionIcon,
111
+ label: (
112
+ <Translate
113
+ id="theme.admonition.caution"
114
+ description="The default label used for the Caution admonition (:::caution)">
115
+ caution
116
+ </Translate>
117
+ ),
80
118
  },
119
+ };
120
+ // Legacy aliases, undocumented but kept for retro-compatibility
121
+ const aliases = {
81
122
  secondary: 'note',
82
123
  important: 'info',
83
124
  success: 'tip',
84
125
  warning: 'danger',
85
126
  };
86
- function getAdmonitionConfig(type) {
127
+ function getAdmonitionConfig(unsafeType) {
128
+ const type = aliases[unsafeType] ?? unsafeType;
87
129
  const config = AdmonitionConfigs[type];
88
130
  if (config) {
89
- if (typeof config === 'string') {
90
- return AdmonitionConfigs[config];
91
- }
92
131
  return config;
93
132
  }
94
133
  console.warn(
@@ -115,26 +154,28 @@ function processAdmonitionProps(props) {
115
154
  const {mdxAdmonitionTitle, rest} = extractMDXAdmonitionTitle(props.children);
116
155
  return {
117
156
  ...props,
118
- title: props.title ?? mdxAdmonitionTitle ?? props.type,
157
+ title: props.title ?? mdxAdmonitionTitle,
119
158
  children: rest,
120
159
  };
121
160
  }
122
161
  export default function Admonition(props) {
123
- const {
124
- children,
125
- type,
126
- title = type,
127
- icon: iconProp,
128
- } = processAdmonitionProps(props);
129
- const config = getAdmonitionConfig(type);
130
- const {infimaClassName, iconComponent: IconComponent} = config;
162
+ const {children, type, title, icon: iconProp} = processAdmonitionProps(props);
163
+ const typeConfig = getAdmonitionConfig(type);
164
+ const titleLabel = title ?? typeConfig.label;
165
+ const {iconComponent: IconComponent} = typeConfig;
131
166
  const icon = iconProp ?? <IconComponent />;
132
167
  return (
133
168
  <div
134
- className={clsx('alert', `alert--${infimaClassName}`, styles.admonition)}>
169
+ className={clsx(
170
+ ThemeClassNames.common.admonition,
171
+ ThemeClassNames.common.admonitionType(props.type),
172
+ 'alert',
173
+ `alert--${typeConfig.infimaClassName}`,
174
+ styles.admonition,
175
+ )}>
135
176
  <div className={styles.admonitionHeading}>
136
177
  <span className={styles.admonitionIcon}>{icon}</span>
137
- {title}
178
+ {titleLabel}
138
179
  </div>
139
180
  <div className={styles.admonitionContent}>{children}</div>
140
181
  </div>
@@ -27,7 +27,10 @@ function LogoImage({logo}) {
27
27
  }
28
28
  export default function FooterLogo({logo}) {
29
29
  return logo.href ? (
30
- <Link href={logo.href} className={styles.footerLogoLink}>
30
+ <Link
31
+ href={logo.href}
32
+ className={styles.footerLogoLink}
33
+ target={logo.target}>
31
34
  <LogoImage logo={logo} />
32
35
  </Link>
33
36
  ) : (
@@ -329,6 +329,7 @@ exports.ThemeConfigSchema = utils_validation_1.Joi.object({
329
329
  width: utils_validation_1.Joi.alternatives().try(utils_validation_1.Joi.string(), utils_validation_1.Joi.number()),
330
330
  height: utils_validation_1.Joi.alternatives().try(utils_validation_1.Joi.string(), utils_validation_1.Joi.number()),
331
331
  href: utils_validation_1.Joi.string(),
332
+ target: utils_validation_1.Joi.string(),
332
333
  }),
333
334
  copyright: utils_validation_1.Joi.string(),
334
335
  links: utils_validation_1.Joi.alternatives(utils_validation_1.Joi.array().items(utils_validation_1.Joi.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-classic",
3
- "version": "0.0.0-5093",
3
+ "version": "0.0.0-5097",
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-5093",
24
- "@docusaurus/mdx-loader": "0.0.0-5093",
25
- "@docusaurus/module-type-aliases": "0.0.0-5093",
26
- "@docusaurus/plugin-content-blog": "0.0.0-5093",
27
- "@docusaurus/plugin-content-docs": "0.0.0-5093",
28
- "@docusaurus/plugin-content-pages": "0.0.0-5093",
29
- "@docusaurus/theme-common": "0.0.0-5093",
30
- "@docusaurus/theme-translations": "0.0.0-5093",
31
- "@docusaurus/types": "0.0.0-5093",
32
- "@docusaurus/utils": "0.0.0-5093",
33
- "@docusaurus/utils-common": "0.0.0-5093",
34
- "@docusaurus/utils-validation": "0.0.0-5093",
23
+ "@docusaurus/core": "0.0.0-5097",
24
+ "@docusaurus/mdx-loader": "0.0.0-5097",
25
+ "@docusaurus/module-type-aliases": "0.0.0-5097",
26
+ "@docusaurus/plugin-content-blog": "0.0.0-5097",
27
+ "@docusaurus/plugin-content-docs": "0.0.0-5097",
28
+ "@docusaurus/plugin-content-pages": "0.0.0-5097",
29
+ "@docusaurus/theme-common": "0.0.0-5097",
30
+ "@docusaurus/theme-translations": "0.0.0-5097",
31
+ "@docusaurus/types": "0.0.0-5097",
32
+ "@docusaurus/utils": "0.0.0-5097",
33
+ "@docusaurus/utils-common": "0.0.0-5097",
34
+ "@docusaurus/utils-validation": "0.0.0-5097",
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": "2aa3114f2c53ba37b785f22ac723059c7a4a75be"
67
+ "gitHead": "11371681cd385f50a760e95d7c977991b8aa5d32"
68
68
  }
@@ -7,6 +7,8 @@
7
7
 
8
8
  import React, {type ReactNode} from 'react';
9
9
  import clsx from 'clsx';
10
+ import {ThemeClassNames} from '@docusaurus/theme-common';
11
+ import Translate from '@docusaurus/Translate';
10
12
  import type {Props} from '@theme/Admonition';
11
13
 
12
14
  import styles from './styles.module.css';
@@ -69,41 +71,82 @@ function CautionIcon() {
69
71
  type AdmonitionConfig = {
70
72
  iconComponent: React.ComponentType;
71
73
  infimaClassName: string;
74
+ label: ReactNode;
72
75
  };
73
76
 
74
- const AdmonitionConfigs: {[key: string]: AdmonitionConfig | string} = {
77
+ // eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
78
+ const AdmonitionConfigs: Record<Props['type'], AdmonitionConfig> = {
75
79
  note: {
76
80
  infimaClassName: 'secondary',
77
81
  iconComponent: NoteIcon,
82
+ label: (
83
+ <Translate
84
+ id="theme.admonition.note"
85
+ description="The default label used for the Note admonition (:::note)">
86
+ note
87
+ </Translate>
88
+ ),
78
89
  },
79
90
  tip: {
80
91
  infimaClassName: 'success',
81
92
  iconComponent: TipIcon,
93
+ label: (
94
+ <Translate
95
+ id="theme.admonition.tip"
96
+ description="The default label used for the Tip admonition (:::tip)">
97
+ tip
98
+ </Translate>
99
+ ),
82
100
  },
83
101
  danger: {
84
102
  infimaClassName: 'danger',
85
103
  iconComponent: DangerIcon,
104
+ label: (
105
+ <Translate
106
+ id="theme.admonition.danger"
107
+ description="The default label used for the Danger admonition (:::danger)">
108
+ danger
109
+ </Translate>
110
+ ),
86
111
  },
87
112
  info: {
88
113
  infimaClassName: 'info',
89
114
  iconComponent: InfoIcon,
115
+ label: (
116
+ <Translate
117
+ id="theme.admonition.info"
118
+ description="The default label used for the Info admonition (:::info)">
119
+ info
120
+ </Translate>
121
+ ),
90
122
  },
91
123
  caution: {
92
124
  infimaClassName: 'warning',
93
125
  iconComponent: CautionIcon,
126
+ label: (
127
+ <Translate
128
+ id="theme.admonition.caution"
129
+ description="The default label used for the Caution admonition (:::caution)">
130
+ caution
131
+ </Translate>
132
+ ),
94
133
  },
134
+ };
135
+
136
+ // Legacy aliases, undocumented but kept for retro-compatibility
137
+ const aliases = {
95
138
  secondary: 'note',
96
139
  important: 'info',
97
140
  success: 'tip',
98
141
  warning: 'danger',
99
- };
142
+ } as const;
100
143
 
101
- function getAdmonitionConfig(type: string): AdmonitionConfig {
144
+ function getAdmonitionConfig(
145
+ unsafeType: Props['type'] | keyof typeof aliases,
146
+ ): AdmonitionConfig {
147
+ const type = aliases[unsafeType as keyof typeof aliases] ?? unsafeType;
102
148
  const config = AdmonitionConfigs[type];
103
149
  if (config) {
104
- if (typeof config === 'string') {
105
- return AdmonitionConfigs[config] as AdmonitionConfig;
106
- }
107
150
  return config;
108
151
  }
109
152
  console.warn(
@@ -136,28 +179,30 @@ function processAdmonitionProps(props: Props): Props {
136
179
  const {mdxAdmonitionTitle, rest} = extractMDXAdmonitionTitle(props.children);
137
180
  return {
138
181
  ...props,
139
- title: props.title ?? mdxAdmonitionTitle ?? props.type,
182
+ title: props.title ?? mdxAdmonitionTitle,
140
183
  children: rest,
141
184
  };
142
185
  }
143
186
 
144
187
  export default function Admonition(props: Props): JSX.Element {
145
- const {
146
- children,
147
- type,
148
- title = type,
149
- icon: iconProp,
150
- } = processAdmonitionProps(props);
188
+ const {children, type, title, icon: iconProp} = processAdmonitionProps(props);
151
189
 
152
- const config = getAdmonitionConfig(type);
153
- const {infimaClassName, iconComponent: IconComponent} = config;
190
+ const typeConfig = getAdmonitionConfig(type);
191
+ const titleLabel = title ?? typeConfig.label;
192
+ const {iconComponent: IconComponent} = typeConfig;
154
193
  const icon = iconProp ?? <IconComponent />;
155
194
  return (
156
195
  <div
157
- className={clsx('alert', `alert--${infimaClassName}`, styles.admonition)}>
196
+ className={clsx(
197
+ ThemeClassNames.common.admonition,
198
+ ThemeClassNames.common.admonitionType(props.type),
199
+ 'alert',
200
+ `alert--${typeConfig.infimaClassName}`,
201
+ styles.admonition,
202
+ )}>
158
203
  <div className={styles.admonitionHeading}>
159
204
  <span className={styles.admonitionIcon}>{icon}</span>
160
- {title}
205
+ {titleLabel}
161
206
  </div>
162
207
  <div className={styles.admonitionContent}>{children}</div>
163
208
  </div>
@@ -32,7 +32,10 @@ function LogoImage({logo}: Props) {
32
32
 
33
33
  export default function FooterLogo({logo}: Props): JSX.Element {
34
34
  return logo.href ? (
35
- <Link href={logo.href} className={styles.footerLogoLink}>
35
+ <Link
36
+ href={logo.href}
37
+ className={styles.footerLogoLink}
38
+ target={logo.target}>
36
39
  <LogoImage logo={logo} />
37
40
  </Link>
38
41
  ) : (
@@ -364,6 +364,7 @@ export const ThemeConfigSchema = Joi.object<ThemeConfig>({
364
364
  width: Joi.alternatives().try(Joi.string(), Joi.number()),
365
365
  height: Joi.alternatives().try(Joi.string(), Joi.number()),
366
366
  href: Joi.string(),
367
+ target: Joi.string(),
367
368
  }),
368
369
  copyright: Joi.string(),
369
370
  links: Joi.alternatives(