From e22b5c2dde66d8f9c96c2a9033d0e1f3b160377d Mon Sep 17 00:00:00 2001 From: Nikhil Kumar Rajak Date: Mon, 29 Jun 2026 12:18:02 +0000 Subject: [PATCH 1/2] fix : version picker to the API docs and highlight the overview as active --- components/SideBar.jsx | 36 ++++++++++++++++++++++++++++----- scripts/markdown/governance.mjs | 7 +++++-- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/components/SideBar.jsx b/components/SideBar.jsx index 725e5e57..e059192b 100644 --- a/components/SideBar.jsx +++ b/components/SideBar.jsx @@ -1,5 +1,8 @@ +import Select from '@node-core/ui-components/Common/Select'; import SideBar from '@node-core/ui-components/Containers/Sidebar'; +import { major } from 'semver'; import { sidebar } from '#theme/local/site'; +import versions from '../versions.json' with { type: 'json' }; /** @param {string} url */ const redirect = url => (window.location.href = url); @@ -12,16 +15,27 @@ const pathnameFor = path => { return clean.startsWith('/') ? clean : `/${clean}`; }; +// The versioned API docs pass `sidebar` as an array of groups; the main site keys it by section. +const isVersioned = Array.isArray(sidebar); + const groupsFor = path => { - if (Array.isArray(sidebar)) return sidebar; + if (isVersioned) return sidebar; const segment = path.split('/').filter(Boolean)[0]; return sidebar[segment] ?? []; }; -/** - * Sidebar component for MDX documentation with page navigation. - */ +const versionItems = versions.map(version => ({ + value: `/docs/api/v${major(version)}.x`, + label: `v${major(version)}.x`, +})); + +// Read the current /docs/api/vX.x base off the sidebar links so the picker preselects it. +const currentVersion = isVersioned + ? JSON.stringify(sidebar).match(/\/docs\/api\/v\d+\.x/)?.[0] + : undefined; + +/** Docs sidebar, plus a webpack version picker on the versioned API docs. */ export default ({ metadata }) => ( ( onSelect={redirect} as={PrefetchLink} title="Navigation" - /> + > + {isVersioned && ( +
+