Skip to content

Commit

Permalink
Add code to generste switcher config
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Electron committed Sep 18, 2023
1 parent 7ce6401 commit 45b0423
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 237 deletions.
239 changes: 3 additions & 236 deletions src/switcher.config.ts
Original file line number Diff line number Diff line change
@@ -1,242 +1,9 @@
import type { Config } from './common/components/Switcher';

const buildDocs = [
{
id: 'iota-sdk-1-0-0',
label: 'IOTA SDK',
description: 'Seamlessly integrate IOTA into your app.',
icon: 'IotaCore',
subsection: 'build-layer-1',
versions: [
{
id: 'iota-sdk-1-0-0',
label: '1.0.0',
badges: ['Shimmer'],
},
],
},
{
id: 'identity-rs-0-5',
label: 'Identity',
description: 'Trustless digital identity management.',
icon: 'Identity',
subsection: 'build-layer-1',
versions: [
{
id: 'identity-rs-next',
label: 'next',
badges: ['Shimmer'],
},
{
id: 'identity-rs-0-7-alpha',
label: '0.7-alpha',
badges: ['Shimmer'],
},
{
id: 'identity-rs-0-6',
label: '0.6',
badges: ['IOTA'],
},
{
id: 'identity-rs-0-5',
label: '0.5',
badges: ['IOTA'],
},
],
},
{
id: 'stronghold-rs',
label: 'Stronghold',
description: 'Securely store secrets.',
icon: 'Stronghold',
subsection: 'build-layer-1',
versions: [
{
id: 'stronghold-rs',
label: '1.1.0',
badges: ['IOTA/Shimmer'],
},
],
},
{
id: 'cli-wallet',
label: 'CLI Wallet',
description: 'Command line wallet.',
icon: 'Wallet',
subsection: 'build-layer-1',
versions: [
{
id: 'cli-wallet',
label: '1.0.0',
badges: ['Shimmer'],
},
],
},
{
id: 'apis',
label: 'APIs',
description: 'All available APIs.',
icon: 'Tools',
subsection: 'build-layer-1',
versions: [
{
id: 'apis',
},
],
},
{
id: 'iota-rs-1-4-0',
label: 'iota.rs (deprecated)',
description: 'Legacy client SDK.',
icon: 'IotaCore',
subsection: 'build-layer-1',
versions: [
{
id: 'iota-rs-2-0-1-rc-7',
label: '2.0.1-rc.7',
badges: ['Shimmer'],
},
{
id: 'iota-rs-1-4-0',
label: '1.4.0',
badges: ['IOTA'],
},
],
},
{
id: 'iotajs',
label: 'iota.js (deprecated)',
description: 'Legacy JavaScript SDK.',
icon: 'IotaCore',
subsection: 'build-layer-1',
versions: [
{
id: 'iotajs',
label: '2.0.0-rc.1',
badges: ['Shimmer'],
},
],
},
{
id: 'wallet-rs-0-1-0',
label: 'wallet.rs (deprecated)',
description: 'Legacy wallet SDK.',
icon: 'Wallet',
subsection: 'build-layer-1',
versions: [
{
id: 'wallet-rs-1-0-0-rc-6',
label: '1.0.0-rc.6',
badges: ['Shimmer'],
},
{
id: 'wallet-rs-0-1-0',
label: '0.1.0',
badges: ['IOTA'],
},
],
},
{
id: 'iota-streams',
label: 'Streams (deprecated)',
description: 'Secure data channels over the Tangle.',
icon: 'Streams',
subsection: 'build-layer-1',
versions: [
{
id: 'iota-streams',
label: '0.2.0',
badges: ['IOTA'],
},
],
},
{
id: 'smart-contract-0-7-0',
label: 'Smart Contracts',
description: 'Create smart contracts.',
icon: 'SmartContracts',
subsection: 'build-layer-2',
versions: [
{
id: 'smart-contract-0-7-0',
label: '0.7.0',
badges: ['Shimmer'],
},
],
},
];

const maintainDocs = [
{
id: 'hornet-1-2-4',
label: 'Hornet',
description: 'The primary node software for IOTA.',
icon: 'Hornet',
subsection: 'maintain-layer-1',
versions: [
{
id: 'hornet-2-0-0-rc-6',
label: '2.0.0-rc.6',
badges: ['Shimmer'],
},
{
id: 'hornet-1-2-4',
label: '1.2.4',
badges: ['IOTA'],
},
],
},
{
id: 'wasp-0-7-0',
label: 'Wasp',
description: 'The node software to run an ISC network',
icon: 'SmartContracts',
subsection: 'maintain-layer-2',
versions: [
{
id: 'wasp-0-7-0',
label: '0.7.0',
badges: ['Shimmer'],
},
],
},
{
id: 'chronicle-rs',
label: 'Chronicle',
description: 'Indexer, archival node, analytics.',
icon: 'Chronicle',
subsection: 'maintain-layer-1',
versions: [
{
id: 'inx-chronicle',
label: '1.0.0-rc.1',
badges: ['Shimmer'],
},
{
id: 'chronicle-rs',
label: '0.3.0',
badges: ['IOTA'],
},
],
},
{
id: 'goshimmer',
label: 'GoShimmer',
description: 'Research node implementation for IOTA 2.0',
icon: 'GoShimmer',
subsection: 'maintain-layer-1',
versions: [
{
id: 'goshimmer',
label: '0.9.8',
badges: ['IOTA 2.0'],
},
],
},
];
import { generateSwitcherConfig } from './utils/pluginConfigGenerators';
const { buildPluginsConfig, maintainPluginsConfig } = require('../versionedConfig');

const config: Config = {
docs: [...buildDocs, ...maintainDocs],
docs: [...generateSwitcherConfig(buildPluginsConfig), ...generateSwitcherConfig(maintainPluginsConfig)],
sections: [
{
before: {
Expand Down
23 changes: 22 additions & 1 deletion src/utils/pluginConfigGenerators.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,28 @@ function generatePluginConfig(pluginConfig, basePath) {
* @param {import('../common/components/Switcher').Doc[]} pluginConfig
*/
function generateSwitcherConfig(pluginConfig) {
return pluginConfig;
let plugins = [];
for (const plugin of pluginConfig) {
//TODO: Rethink how we use ids in the switcher and/or determine the main plugin id
const firstLabel = plugin.versions[0].label;
plugins.push({
id: plugin.id + (firstLabel ? '-' + firstLabel.replace(/\./g, '-') : ''),
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;
};

module.exports = {
Expand Down

0 comments on commit 45b0423

Please sign in to comment.