Skip to content

Commit

Permalink
Update src/utils/pluginConfigGenerators.js
Browse files Browse the repository at this point in the history
Co-authored-by: Jeroen van den Hout <[email protected]>
  • Loading branch information
Dr-Electron and jlvandenhout authored Sep 23, 2023
1 parent a4a8c28 commit 7c5dac2
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions src/utils/pluginConfigGenerators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 7c5dac2

Please sign in to comment.