From 786ccfaf444fdc34e3256e31f1ec093461328f5f Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Thu, 4 Jul 2024 21:08:36 +0200 Subject: [PATCH] Allow undefined badges --- config/versionedConfig.js | 2 -- src/utils/pluginConfigGenerators.js | 7 ++++--- src/utils/useSwitcher.ts | 4 +++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/config/versionedConfig.js b/config/versionedConfig.js index d549fb45e34..744d29f0788 100644 --- a/config/versionedConfig.js +++ b/config/versionedConfig.js @@ -28,7 +28,6 @@ exports.buildPluginsConfig = [ versions: [ { label: 'v1.1', - badges: [], banner: 'unmaintained', }, { @@ -155,7 +154,6 @@ exports.maintainPluginsConfig = [ versions: [ { label: 'v1.1', - badges: [], banner: 'unmaintained', }, { diff --git a/src/utils/pluginConfigGenerators.js b/src/utils/pluginConfigGenerators.js index 4cd7f6769f3..511ff1227ca 100644 --- a/src/utils/pluginConfigGenerators.js +++ b/src/utils/pluginConfigGenerators.js @@ -4,17 +4,18 @@ const MAIN_BADGE = 'IOTA'; /** * Find main version of a plugin by resolving it to the first version with the corresponding batch. - * @param {import('../common/components/Switcher').Doc} plugin + * @param {import('../components/Switcher').Doc} plugin + * @param {string} badge */ function findMainVersion(plugin, badge = MAIN_BADGE) { return plugin.versions.find((version) => - version.badges.some((b) => b.includes(badge)), + version.badges ? version.badges.some((b) => b.includes(badge)) : false, ); } /** * Generate the plugin config from the versioned config. - * @param {import('../common/components/Switcher').Doc[]} pluginConfig + * @param {import('../components/Switcher').Doc[]} pluginConfig * @param {string} basePath */ function generatePluginConfig(pluginConfig, basePath) { diff --git a/src/utils/useSwitcher.ts b/src/utils/useSwitcher.ts index 0b459a5717b..0d99a373f09 100644 --- a/src/utils/useSwitcher.ts +++ b/src/utils/useSwitcher.ts @@ -137,7 +137,9 @@ export default function useSwitcher(): SwitcherProps { // Resolve the doc link to the first MAIN_BADGE version. let to = versionLinks[0].to; const foundVersion = versionLinks.find((version) => - version.badges.some((b) => b.includes(MAIN_BADGE)), + version.badges + ? version.badges.some((b) => b.includes(MAIN_BADGE)) + : false, ); if (foundVersion) to = foundVersion.to;