@@ -68,20 +68,20 @@ function getTargetLink(platformId: string, targetLabel?: string, activeId?: stri
6868 // 1. If current is overview, always try to land on target's overview
6969 if (isCurrentOverview ) {
7070 const targetOverview = findOverview (sidebarData );
71- if (targetOverview ) return ` /${targetOverview .id } ` ;
71+ if (targetOverview ) return ` ${ import . meta . env . BASE_URL } /${targetOverview .id }` . replace ( / \/ + / g , ' / ' ) ;
7272 }
7373
7474 // 2. Otherwise, try to find matching label first (Topic Consistency)
7575 if (targetLabel ) {
7676 const match = findItemByLabel (sidebarData , targetLabel );
77- if (match ) return ` /${match .id } ` ;
77+ if (match ) return ` ${ import . meta . env . BASE_URL } /${match .id }` . replace ( / \/ + / g , ' / ' ) ;
7878 }
7979
8080 // 3. Last Fallback: Target platform's overview
8181 const overview = findOverview (sidebarData );
82- if (overview ) return ` /${overview .id } ` ;
82+ if (overview ) return ` ${ import . meta . env . BASE_URL } /${overview .id }` . replace ( / \/ + / g , ' / ' ) ;
8383
84- return ` /${platformId }-sdk-overview ` ; // Ultimate hardcoded fallback
84+ return ` ${ import . meta . env . BASE_URL } /${platformId }-sdk-overview` . replace ( / \/ + / g , ' / ' ) ; // Ultimate hardcoded fallback
8585}
8686---
8787
@@ -346,11 +346,12 @@ function getTargetLink(platformId: string, targetLabel?: string, activeId?: stri
346346 }
347347
348348 function getTargetLink(platformId: string, sidebarName: string): string {
349+ const baseUrl = import.meta.env.BASE_URL;
349350 // Remove .json extension if present
350351 const cleanSidebarName = sidebarName.replace('.json', '');
351352 const sidebarData = sidebarsMap.get(cleanSidebarName);
352353 if (!sidebarData) {
353- return `/${platformId}-sdk-overview`;
354+ return `${baseUrl} /${platformId}-sdk-overview`.replace(/\/+/g, '/') ;
354355 }
355356
356357 // Get current page info dynamically
@@ -375,25 +376,25 @@ function getTargetLink(platformId: string, targetLabel?: string, activeId?: stri
375376 if (isCurrentOverview) {
376377 const targetOverview = findOverview(sidebarData);
377378 if (targetOverview) {
378- return `/${targetOverview.id}`;
379+ return `${baseUrl} /${targetOverview.id}`.replace(/\/+/g, '/') ;
379380 }
380381 }
381382
382383 // 2. Try to find matching label (Topic Consistency)
383384 if (currentLabel) {
384385 const match = findItemByLabel(sidebarData, currentLabel);
385386 if (match) {
386- return `/${match.id}`;
387+ return `${baseUrl} /${match.id}`.replace(/\/+/g, '/') ;
387388 }
388389 }
389390
390391 // 3. Fallback to target's overview
391392 const overview = findOverview(sidebarData);
392393 if (overview) {
393- return `/${overview.id}`;
394+ return `${baseUrl} /${overview.id}`.replace(/\/+/g, '/') ;
394395 }
395396
396- return `/${platformId}-sdk-overview`;
397+ return `${baseUrl} /${platformId}-sdk-overview`.replace(/\/+/g, '/') ;
397398 }
398399
399400 function initPlatformSwitcher() {
0 commit comments