@chargeover/redocusaurus
Version:
Redoc for DocusaurusV2
51 lines • 1.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
function preset(context, opts = {
specs: [],
theme: {},
}) {
let specsArray = [];
const { debug = false, specs, theme = {} } = opts;
if (debug) {
console.error('[REDOCUSAURUS] Options:', opts);
}
if (Array.isArray(specs)) {
specsArray = specs;
}
else if (specs) {
specsArray = [specs];
}
if (debug) {
console.error('[REDOCUSAURUS] Specs:', specsArray);
}
const id = opts.id ? `-${opts.id}` : '';
const themeId = `theme-redoc${id}`;
const config = {
themes: [
[
require.resolve('@chargeover/docusaurus-theme-redoc'),
{
id: themeId,
...theme,
},
],
],
plugins: [
...specsArray.map((pluginOpts, index) => [
require.resolve('@chargeover/docusaurus-plugin-redoc'),
{
...pluginOpts,
themeId,
id: pluginOpts.id || `plugin-redoc${id}-${index}`,
debug,
},
]),
],
};
if (debug) {
console.error('[REDOCUSAURUS] Final:', JSON.stringify(config, null, 2));
}
return config;
}
exports.default = preset;
//# sourceMappingURL=index.js.map