forked from ionic-team/ionic-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
54 lines (49 loc) · 1.7 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
45
46
47
48
49
50
51
52
53
54
const path = require('path');
const { Joi } = require('@docusaurus/utils-validation');
const theme = require(path.resolve(__dirname, '../../node_modules/@docusaurus/theme-classic/lib'));
const themePath = path.resolve(__dirname, '../../node_modules/@docusaurus/theme-classic/lib-next/theme');
const tsThemePath = path.resolve(__dirname, '../../node_modules/@docusaurus/theme-classic/src/theme');
let { ThemeConfigSchema } = require(path.resolve(
__dirname,
'../../node_modules/@docusaurus/theme-classic/lib/validateThemeConfig.js'
));
const NavbarCtaSchema = Joi.object({
type: Joi.string().equal('cta').required(),
position: Joi.string().default('left'),
text: Joi.string().required(),
href: Joi.string().required(),
});
const NavbarIconLinkSchema = Joi.object({
type: Joi.string().equal('iconLink').required(),
position: Joi.string().default('left'),
icon: Joi.object({
alt: Joi.string().default('icon link'),
src: Joi.string(),
href: Joi.string(),
target: Joi.string().default('_self'),
width: Joi.number(),
height: Joi.number(),
}),
});
const NavbarSeparatorSchema = Joi.object({
type: Joi.string().equal('separator').required(),
position: Joi.string().default('left'),
});
ThemeConfigSchema = ThemeConfigSchema.concat(
Joi.object({
navbar: { items: Joi.array().items(NavbarIconLinkSchema).items(NavbarSeparatorSchema).items(NavbarCtaSchema) },
})
);
module.exports = {
...theme,
default: (config, opts) => ({
...theme.default(config, opts),
getThemePath() {
return themePath;
},
getTypescriptThemePath() {
return tsThemePath;
},
}),
validateThemeConfig: ({ validate, themeConfig }) => validate(ThemeConfigSchema, themeConfig),
};