-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (38 loc) · 1.17 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const path = require('path');
const { Joi } = require('@docusaurus/utils-validation');
const theme = require('@docusaurus/theme-classic/lib');
const packageName = '@docusaurus/theme-classic';
const themeClassicDir = require.resolve(packageName);
const baseDir = `${themeClassicDir.split(packageName)[0]}${packageName}`;
const themePath = path.join(baseDir, 'lib-next/theme');
const tsThemePath = path.join(baseDir, 'src/theme');
let { ThemeConfigSchema } = require('@docusaurus/theme-classic/lib/validateThemeConfig.js');
module.exports = {
...theme,
default: (config, opts) => {
return {
...theme.default(config, opts),
getThemePath() {
return themePath;
},
getTypescriptThemePath() {
return tsThemePath;
},
};
},
validateThemeConfig: ({ validate, themeConfig }) => {
const {
customSchema: {
navbar: { items },
},
} = themeConfig;
const CustomThemeConfigSchema = ThemeConfigSchema.concat(
Joi.object({
navbar: {
items: items.reduce((acc, cur) => acc.items(cur), Joi.array()),
},
})
);
return validate(CustomThemeConfigSchema, themeConfig);
},
};