@docusaurus/theme-classic 0.0.0-5189 → 0.0.0-5195
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/index.d.ts +3 -3
- package/lib/index.js +6 -7
- package/lib/{validateThemeConfig.d.ts → options.d.ts} +3 -1
- package/lib/{validateThemeConfig.js → options.js} +19 -5
- package/package.json +14 -14
- package/src/index.ts +5 -11
- package/src/{validateThemeConfig.ts → options.ts} +31 -6
- package/src/theme-classic.d.ts +5 -1
package/lib/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { LoadContext, Plugin } from '@docusaurus/types';
|
|
8
|
-
import type {
|
|
8
|
+
import type { PluginOptions } from '@docusaurus/theme-classic';
|
|
9
9
|
export declare const AnnouncementBarDismissStorageKey = "docusaurus.announcement.dismiss";
|
|
10
|
-
export default function themeClassic(context: LoadContext, options:
|
|
10
|
+
export default function themeClassic(context: LoadContext, options: PluginOptions): Plugin<undefined>;
|
|
11
11
|
export { default as getSwizzleConfig } from './getSwizzleConfig';
|
|
12
|
-
export { validateThemeConfig } from './
|
|
12
|
+
export { validateThemeConfig, validateOptions } from './options';
|
package/lib/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.validateThemeConfig = exports.getSwizzleConfig = exports.AnnouncementBarDismissStorageKey = void 0;
|
|
9
|
+
exports.validateOptions = exports.validateThemeConfig = exports.getSwizzleConfig = exports.AnnouncementBarDismissStorageKey = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
12
|
const module_1 = require("module");
|
|
@@ -82,7 +82,7 @@ function themeClassic(context, options) {
|
|
|
82
82
|
const { i18n: { currentLocale, localeConfigs }, } = context;
|
|
83
83
|
const themeConfig = context.siteConfig.themeConfig;
|
|
84
84
|
const { announcementBar, colorMode, prism: { additionalLanguages }, } = themeConfig;
|
|
85
|
-
const { customCss } = options
|
|
85
|
+
const { customCss } = options;
|
|
86
86
|
const { direction } = localeConfigs[currentLocale];
|
|
87
87
|
return {
|
|
88
88
|
name: 'docusaurus-theme-classic',
|
|
@@ -109,9 +109,7 @@ function themeClassic(context, options) {
|
|
|
109
109
|
'./prism-include-languages',
|
|
110
110
|
'./nprogress',
|
|
111
111
|
];
|
|
112
|
-
|
|
113
|
-
modules.push(...(Array.isArray(customCss) ? customCss : [customCss]).map((p) => path_1.default.resolve(context.siteDir, p)));
|
|
114
|
-
}
|
|
112
|
+
modules.push(...customCss.map((p) => path_1.default.resolve(context.siteDir, p)));
|
|
115
113
|
return modules;
|
|
116
114
|
},
|
|
117
115
|
configureWebpack() {
|
|
@@ -163,5 +161,6 @@ ${announcementBar ? AnnouncementBarInlineJavaScript : ''}
|
|
|
163
161
|
exports.default = themeClassic;
|
|
164
162
|
var getSwizzleConfig_1 = require("./getSwizzleConfig");
|
|
165
163
|
Object.defineProperty(exports, "getSwizzleConfig", { enumerable: true, get: function () { return tslib_1.__importDefault(getSwizzleConfig_1).default; } });
|
|
166
|
-
var
|
|
167
|
-
Object.defineProperty(exports, "validateThemeConfig", { enumerable: true, get: function () { return
|
|
164
|
+
var options_1 = require("./options");
|
|
165
|
+
Object.defineProperty(exports, "validateThemeConfig", { enumerable: true, get: function () { return options_1.validateThemeConfig; } });
|
|
166
|
+
Object.defineProperty(exports, "validateOptions", { enumerable: true, get: function () { return options_1.validateOptions; } });
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { Joi } from '@docusaurus/utils-validation';
|
|
8
|
+
import type { Options, PluginOptions } from '@docusaurus/theme-classic';
|
|
8
9
|
import type { ThemeConfig } from '@docusaurus/theme-common';
|
|
9
|
-
import type { ThemeConfigValidationContext } from '@docusaurus/types';
|
|
10
|
+
import type { ThemeConfigValidationContext, OptionValidationContext } from '@docusaurus/types';
|
|
10
11
|
export declare const DEFAULT_CONFIG: ThemeConfig;
|
|
11
12
|
export declare const ThemeConfigSchema: Joi.ObjectSchema<ThemeConfig>;
|
|
12
13
|
export declare function validateThemeConfig({ validate, themeConfig, }: ThemeConfigValidationContext<ThemeConfig>): ThemeConfig;
|
|
14
|
+
export declare function validateOptions({ validate, options, }: OptionValidationContext<Options, PluginOptions>): PluginOptions;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.validateThemeConfig = exports.ThemeConfigSchema = exports.DEFAULT_CONFIG = void 0;
|
|
9
|
+
exports.validateOptions = exports.validateThemeConfig = exports.ThemeConfigSchema = exports.DEFAULT_CONFIG = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const palenight_1 = tslib_1.__importDefault(require("prism-react-renderer/themes/palenight"));
|
|
12
12
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
@@ -265,9 +265,6 @@ const FooterLinkItemSchema = utils_validation_1.Joi.object({
|
|
|
265
265
|
// We allow any unknown attributes on the links (users may need additional
|
|
266
266
|
// attributes like target, aria-role, data-customAttribute...)
|
|
267
267
|
.unknown();
|
|
268
|
-
const CustomCssSchema = utils_validation_1.Joi.alternatives()
|
|
269
|
-
.try(utils_validation_1.Joi.array().items(utils_validation_1.Joi.string().required()), utils_validation_1.Joi.string().required())
|
|
270
|
-
.optional();
|
|
271
268
|
const LogoSchema = utils_validation_1.Joi.object({
|
|
272
269
|
alt: utils_validation_1.Joi.string().allow(''),
|
|
273
270
|
src: utils_validation_1.Joi.string().required(),
|
|
@@ -289,7 +286,6 @@ exports.ThemeConfigSchema = utils_validation_1.Joi.object({
|
|
|
289
286
|
defaultDarkMode: utils_validation_1.Joi.any().forbidden().messages({
|
|
290
287
|
'any.unknown': 'defaultDarkMode theme config is deprecated. Please use the new colorMode attribute. You likely want: config.themeConfig.colorMode.defaultMode = "dark"',
|
|
291
288
|
}),
|
|
292
|
-
customCss: CustomCssSchema,
|
|
293
289
|
colorMode: ColorModeSchema,
|
|
294
290
|
image: utils_validation_1.Joi.string(),
|
|
295
291
|
docs: DocsSchema,
|
|
@@ -393,3 +389,21 @@ function validateThemeConfig({ validate, themeConfig, }) {
|
|
|
393
389
|
return validate(exports.ThemeConfigSchema, themeConfig);
|
|
394
390
|
}
|
|
395
391
|
exports.validateThemeConfig = validateThemeConfig;
|
|
392
|
+
const DEFAULT_OPTIONS = {
|
|
393
|
+
customCss: [],
|
|
394
|
+
};
|
|
395
|
+
const PluginOptionSchema = utils_validation_1.Joi.object({
|
|
396
|
+
customCss: utils_validation_1.Joi.alternatives()
|
|
397
|
+
.try(utils_validation_1.Joi.array().items(utils_validation_1.Joi.string().required()), utils_validation_1.Joi.alternatives().conditional(utils_validation_1.Joi.string().required(), {
|
|
398
|
+
then: utils_validation_1.Joi.custom((val) => [val]),
|
|
399
|
+
otherwise: utils_validation_1.Joi.forbidden().messages({
|
|
400
|
+
'any.unknown': '"customCss" must be a string or an array of strings',
|
|
401
|
+
}),
|
|
402
|
+
}))
|
|
403
|
+
.default(DEFAULT_OPTIONS.customCss),
|
|
404
|
+
});
|
|
405
|
+
function validateOptions({ validate, options, }) {
|
|
406
|
+
const validatedOptions = validate(PluginOptionSchema, options);
|
|
407
|
+
return validatedOptions;
|
|
408
|
+
}
|
|
409
|
+
exports.validateOptions = validateOptions;
|
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-5195",
|
|
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-5195",
|
|
24
|
+
"@docusaurus/mdx-loader": "0.0.0-5195",
|
|
25
|
+
"@docusaurus/module-type-aliases": "0.0.0-5195",
|
|
26
|
+
"@docusaurus/plugin-content-blog": "0.0.0-5195",
|
|
27
|
+
"@docusaurus/plugin-content-docs": "0.0.0-5195",
|
|
28
|
+
"@docusaurus/plugin-content-pages": "0.0.0-5195",
|
|
29
|
+
"@docusaurus/theme-common": "0.0.0-5195",
|
|
30
|
+
"@docusaurus/theme-translations": "0.0.0-5195",
|
|
31
|
+
"@docusaurus/types": "0.0.0-5195",
|
|
32
|
+
"@docusaurus/utils": "0.0.0-5195",
|
|
33
|
+
"@docusaurus/utils-common": "0.0.0-5195",
|
|
34
|
+
"@docusaurus/utils-validation": "0.0.0-5195",
|
|
35
35
|
"@mdx-js/react": "^1.6.22",
|
|
36
36
|
"clsx": "^1.2.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": "d785bdfb02c7995d5bc95e82734110c1b79d7174"
|
|
68
68
|
}
|
package/src/index.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {getTranslationFiles, translateThemeConfig} from './translations';
|
|
|
13
13
|
import type {LoadContext, Plugin} from '@docusaurus/types';
|
|
14
14
|
import type {ThemeConfig} from '@docusaurus/theme-common';
|
|
15
15
|
import type {Plugin as PostCssPlugin} from 'postcss';
|
|
16
|
-
import type {
|
|
16
|
+
import type {PluginOptions} from '@docusaurus/theme-classic';
|
|
17
17
|
import type webpack from 'webpack';
|
|
18
18
|
|
|
19
19
|
const requireFromDocusaurusCore = createRequire(
|
|
@@ -98,7 +98,7 @@ function getInfimaCSSFile(direction: string) {
|
|
|
98
98
|
|
|
99
99
|
export default function themeClassic(
|
|
100
100
|
context: LoadContext,
|
|
101
|
-
options:
|
|
101
|
+
options: PluginOptions,
|
|
102
102
|
): Plugin<undefined> {
|
|
103
103
|
const {
|
|
104
104
|
i18n: {currentLocale, localeConfigs},
|
|
@@ -109,7 +109,7 @@ export default function themeClassic(
|
|
|
109
109
|
colorMode,
|
|
110
110
|
prism: {additionalLanguages},
|
|
111
111
|
} = themeConfig;
|
|
112
|
-
const {customCss} = options
|
|
112
|
+
const {customCss} = options;
|
|
113
113
|
const {direction} = localeConfigs[currentLocale]!;
|
|
114
114
|
|
|
115
115
|
return {
|
|
@@ -145,13 +145,7 @@ export default function themeClassic(
|
|
|
145
145
|
'./nprogress',
|
|
146
146
|
];
|
|
147
147
|
|
|
148
|
-
|
|
149
|
-
modules.push(
|
|
150
|
-
...(Array.isArray(customCss) ? customCss : [customCss]).map((p) =>
|
|
151
|
-
path.resolve(context.siteDir, p),
|
|
152
|
-
),
|
|
153
|
-
);
|
|
154
|
-
}
|
|
148
|
+
modules.push(...customCss.map((p) => path.resolve(context.siteDir, p)));
|
|
155
149
|
|
|
156
150
|
return modules;
|
|
157
151
|
},
|
|
@@ -211,4 +205,4 @@ ${announcementBar ? AnnouncementBarInlineJavaScript : ''}
|
|
|
211
205
|
}
|
|
212
206
|
|
|
213
207
|
export {default as getSwizzleConfig} from './getSwizzleConfig';
|
|
214
|
-
export {validateThemeConfig} from './
|
|
208
|
+
export {validateThemeConfig, validateOptions} from './options';
|
|
@@ -7,8 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
import defaultPrismTheme from 'prism-react-renderer/themes/palenight';
|
|
9
9
|
import {Joi, URISchema} from '@docusaurus/utils-validation';
|
|
10
|
+
import type {Options, PluginOptions} from '@docusaurus/theme-classic';
|
|
10
11
|
import type {ThemeConfig} from '@docusaurus/theme-common';
|
|
11
|
-
import type {
|
|
12
|
+
import type {
|
|
13
|
+
ThemeConfigValidationContext,
|
|
14
|
+
OptionValidationContext,
|
|
15
|
+
} from '@docusaurus/types';
|
|
12
16
|
|
|
13
17
|
const DEFAULT_DOCS_CONFIG: ThemeConfig['docs'] = {
|
|
14
18
|
versionPersistence: 'localStorage',
|
|
@@ -296,10 +300,6 @@ const FooterLinkItemSchema = Joi.object({
|
|
|
296
300
|
// attributes like target, aria-role, data-customAttribute...)
|
|
297
301
|
.unknown();
|
|
298
302
|
|
|
299
|
-
const CustomCssSchema = Joi.alternatives()
|
|
300
|
-
.try(Joi.array().items(Joi.string().required()), Joi.string().required())
|
|
301
|
-
.optional();
|
|
302
|
-
|
|
303
303
|
const LogoSchema = Joi.object({
|
|
304
304
|
alt: Joi.string().allow(''),
|
|
305
305
|
src: Joi.string().required(),
|
|
@@ -324,7 +324,6 @@ export const ThemeConfigSchema = Joi.object<ThemeConfig>({
|
|
|
324
324
|
'any.unknown':
|
|
325
325
|
'defaultDarkMode theme config is deprecated. Please use the new colorMode attribute. You likely want: config.themeConfig.colorMode.defaultMode = "dark"',
|
|
326
326
|
}),
|
|
327
|
-
customCss: CustomCssSchema,
|
|
328
327
|
colorMode: ColorModeSchema,
|
|
329
328
|
image: Joi.string(),
|
|
330
329
|
docs: DocsSchema,
|
|
@@ -442,3 +441,29 @@ export function validateThemeConfig({
|
|
|
442
441
|
}: ThemeConfigValidationContext<ThemeConfig>): ThemeConfig {
|
|
443
442
|
return validate(ThemeConfigSchema, themeConfig);
|
|
444
443
|
}
|
|
444
|
+
|
|
445
|
+
const DEFAULT_OPTIONS = {
|
|
446
|
+
customCss: [],
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
const PluginOptionSchema = Joi.object<PluginOptions>({
|
|
450
|
+
customCss: Joi.alternatives()
|
|
451
|
+
.try(
|
|
452
|
+
Joi.array().items(Joi.string().required()),
|
|
453
|
+
Joi.alternatives().conditional(Joi.string().required(), {
|
|
454
|
+
then: Joi.custom((val: string) => [val]),
|
|
455
|
+
otherwise: Joi.forbidden().messages({
|
|
456
|
+
'any.unknown': '"customCss" must be a string or an array of strings',
|
|
457
|
+
}),
|
|
458
|
+
}),
|
|
459
|
+
)
|
|
460
|
+
.default(DEFAULT_OPTIONS.customCss),
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
export function validateOptions({
|
|
464
|
+
validate,
|
|
465
|
+
options,
|
|
466
|
+
}: OptionValidationContext<Options, PluginOptions>): PluginOptions {
|
|
467
|
+
const validatedOptions = validate(PluginOptionSchema, options);
|
|
468
|
+
return validatedOptions;
|
|
469
|
+
}
|
package/src/theme-classic.d.ts
CHANGED
|
@@ -23,8 +23,12 @@
|
|
|
23
23
|
declare module '@docusaurus/theme-classic' {
|
|
24
24
|
import type {LoadContext, Plugin, PluginModule} from '@docusaurus/types';
|
|
25
25
|
|
|
26
|
+
export type PluginOptions = {
|
|
27
|
+
customCss: string[];
|
|
28
|
+
};
|
|
29
|
+
|
|
26
30
|
export type Options = {
|
|
27
|
-
customCss?: string | string
|
|
31
|
+
customCss?: string[] | string;
|
|
28
32
|
};
|
|
29
33
|
|
|
30
34
|
export const getSwizzleConfig: PluginModule['getSwizzleConfig'];
|