From 7c5dac2ee384e8cbef78e2387eb59a76a13f1410 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Sat, 23 Sep 2023 22:54:11 +0200 Subject: [PATCH] Update src/utils/pluginConfigGenerators.js Co-authored-by: Jeroen van den Hout --- src/utils/pluginConfigGenerators.js | 34 ++++++++++------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/utils/pluginConfigGenerators.js b/src/utils/pluginConfigGenerators.js index b17123d0345..d3ed40a7c9e 100644 --- a/src/utils/pluginConfigGenerators.js +++ b/src/utils/pluginConfigGenerators.js @@ -56,29 +56,17 @@ function generatePluginConfig(pluginConfig, basePath) { * @param {import('../common/components/Switcher').Doc[]} pluginConfig */ function generateSwitcherConfig(pluginConfig) { - let plugins = []; - for (const plugin of pluginConfig) { - plugins.push({ - // Here any unique id could be uses as this is just used to track the active plugin in the switcher. - // So we use the plugin id without version label. So it actually isn't the actual plugin id of the plugin. - // Confusing, I know ;) - id: plugin.id, - label: plugin.label, - icon: plugin.icon, - description: plugin.description, - subsection: plugin.subsection, - versions: plugin.versions.map((version) => { - const { label, badges } = version; - return { - id: plugin.id + (label ? '-' + label.replace(/\./g, '-') : ''), - label: label, - badges: badges, - }; - }), - }); - } - - return plugins; + return pluginConfig.map((plugin) => ({ + ...plugin, + versions: plugin.versions.map((version) => { + const { label, badges } = version; + return { + id: plugin.id + (label ? '-' + label.replace(/\./g, '-') : ''), + label, + badges, + }; + }), + }); } module.exports = {