Skip to content

Commit

Permalink
Allow undefined badges
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Electron committed Jul 4, 2024
1 parent 5c14531 commit 786ccfa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 0 additions & 2 deletions config/versionedConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ exports.buildPluginsConfig = [
versions: [
{
label: 'v1.1',
badges: [],
banner: 'unmaintained',
},
{
Expand Down Expand Up @@ -155,7 +154,6 @@ exports.maintainPluginsConfig = [
versions: [
{
label: 'v1.1',
badges: [],
banner: 'unmaintained',
},
{
Expand Down
7 changes: 4 additions & 3 deletions src/utils/pluginConfigGenerators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/useSwitcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 786ccfa

Please sign in to comment.