@@ -3,6 +3,7 @@ import SideBar from '@node-core/ui-components/Containers/Sidebar';
33import { major } from 'semver' ;
44import { sidebar } from '#theme/local/site' ;
55import { version } from '#theme/config' ;
6+ import { toPublicLink } from '../utils/helpers/urls.mjs' ;
67import versions from '../versions.json' with { type : 'json' } ;
78
89/** @param {string } url */
@@ -16,11 +17,6 @@ const isVersioned = Array.isArray(sidebar);
1617// Versioned pages expose a version relative path, we prefix it so it matches the absolute sidebar links.
1718const versionBase = isVersioned ? `/docs/api/v${ version . major } .x` : '' ;
1819
19- const pathnameFor = path => {
20- const clean = path . replace ( / \/ i n d e x $ / , '' ) . replace ( / ^ \/ / , '' ) ;
21- return ( clean ? `${ versionBase } /${ clean } ` : versionBase ) || '/' ;
22- } ;
23-
2420const groupsFor = path => {
2521 if ( isVersioned ) return sidebar ;
2622
@@ -39,7 +35,7 @@ const currentVersion = isVersioned ? versionBase : undefined;
3935/** Docs sidebar, plus a webpack version picker on the versioned API docs. */
4036export default ( { metadata } ) => (
4137 < SideBar
42- pathname = { pathnameFor ( metadata . path ) }
38+ pathname = { toPublicLink ( metadata . path , versionBase ) }
4339 groups = { groupsFor ( metadata . path ) }
4440 onSelect = { redirect }
4541 as = { PrefetchLink }
0 commit comments