forked from cloud-annotations/docusaurus-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
41 lines (33 loc) · 1.21 KB
/
index.ts
File metadata and controls
41 lines (33 loc) · 1.21 KB
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
/* ============================================================================
* Copyright (c) Cloud Annotations
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* ========================================================================== */
import presetClassic from "@docusaurus/preset-classic";
import type { Preset, LoadContext, PluginOptions } from "@docusaurus/types";
import type { Options } from "docusaurus-preset-openapi";
function makePluginConfig(
source: string,
options?: PluginOptions
): string | [string, PluginOptions] {
if (options) {
return [require.resolve(source), options];
}
return require.resolve(source);
}
export default function preset(
context: LoadContext,
options: Options = {}
): Preset {
const { proxy, api, ...rest } = options;
const { themes = [], plugins = [] } = presetClassic(context, rest);
themes.push(makePluginConfig("docusaurus-theme-openapi"));
if (api !== false) {
plugins.push(makePluginConfig("docusaurus-plugin-openapi", api));
}
if (proxy !== false) {
plugins.push(makePluginConfig("docusaurus-plugin-proxy", { proxy }));
}
return { themes, plugins };
}