-
Notifications
You must be signed in to change notification settings - Fork 115
/
index.ts
67 lines (61 loc) · 1.84 KB
/
index.ts
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
55
56
57
58
59
60
61
62
63
64
65
66
67
import path from 'path';
import type { LoadContext, Plugin } from '@docusaurus/types';
import { ThemeOptions, GlobalData } from './types/options';
import { getGlobalData } from './redocData';
// eslint-disable-next-line import/no-extraneous-dependencies, import/order
import webpack from 'webpack';
export { ThemeOptions, GlobalData };
export default function redocTheme(
context: LoadContext,
options: ThemeOptions,
): Plugin<null> {
return {
name: 'docusaurus-theme-redoc',
configureWebpack(_config, isServer) {
return {
plugins: [
new webpack.NormalModuleReplacementPlugin(
/^tty$/,
require.resolve('./tty'),
),
new webpack.DefinePlugin({
'process.versions.node': JSON.stringify(
process.versions.node || '0.0.0',
),
'process.platform': JSON.stringify(''),
'process.env': JSON.stringify({}),
}),
...(isServer
? [
new webpack.NormalModuleReplacementPlugin(
/theme\/Redoc\/Styles/,
path.join(__dirname, 'theme', 'Redoc', 'ServerStyles.js'),
),
]
: []),
],
};
},
async contentLoaded({ actions }) {
const { setGlobalData } = actions;
const globalData = getGlobalData(options);
setGlobalData(globalData);
},
getThemePath() {
return path.join(__dirname, '..', 'dist-jsx', 'theme');
},
getTypeScriptThemePath() {
return path.join(__dirname, '..', 'src', 'theme');
},
getClientModules() {
return [
path.join(__dirname, 'custom.css'),
path.join(__dirname, 'global.js'),
];
},
};
}
const getSwizzleComponentList = (): string[] => {
return ['Redoc', 'ApiDoc'];
};
export { getSwizzleComponentList };