File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -848,6 +848,8 @@ export function DocsLayout({
848848 } )
849849 } , [ groupInitialOpenState ] )
850850
851+ const libraryHomePath = `/${ libraryId } /${ version } `
852+
851853 const menuItems = menuConfig . map ( ( group , i ) => {
852854 const groupKey = `${ i } :${ String ( group . label ) } `
853855
@@ -919,8 +921,7 @@ export function DocsLayout({
919921 </ a >
920922 ) : isHomeLink ? (
921923 < Link
922- to = "/$libraryId/$version"
923- params = { { libraryId, version } }
924+ to = { libraryHomePath }
924925 onClick = { ( ) => {
925926 detailsRef . current . removeAttribute ( 'open' )
926927 } }
Original file line number Diff line number Diff line change @@ -29,6 +29,24 @@ function isRoutableInternalLink(link: string) {
2929 )
3030}
3131
32+ function normalizeRoutableInternalPathname ( pathname : string ) {
33+ const routerFrameworkMatch = pathname . match (
34+ / ^ \/ r o u t e r \/ ( [ ^ / ] + ) \/ d o c s \/ f r a m e w o r k \/ [ ^ / ] + \/ ( .+ ) $ / ,
35+ )
36+
37+ if ( ! routerFrameworkMatch ) {
38+ return pathname
39+ }
40+
41+ const [ , version , docsPath ] = routerFrameworkMatch
42+
43+ if ( ! version || ! docsPath || docsPath . startsWith ( 'examples/' ) ) {
44+ return pathname
45+ }
46+
47+ return `/router/${ version } /docs/${ docsPath } `
48+ }
49+
3250export function MarkdownLink ( {
3351 href : hrefProp ,
3452 ...rest
@@ -37,14 +55,16 @@ export function MarkdownLink({
3755
3856 if ( isRoutableInternalLink ( href ) ) {
3957 const [ hrefWithoutHash , hash ] = href . split ( '#' )
40- const hrefWithoutMd = hrefWithoutHash . replace ( '.md' , '' )
58+ const hrefWithoutMd = normalizeRoutableInternalPathname (
59+ hrefWithoutHash . replace ( '.md' , '' ) ,
60+ )
4161
4262 return (
4363 < Link
4464 { ...rest }
4565 to = { hrefWithoutMd }
4666 hash = { hash }
47- preload = { undefined }
67+ preload = { false }
4868 ref = { undefined }
4969 />
5070 )
@@ -73,7 +93,7 @@ export function MarkdownLink({
7393 unsafeRelative = "path"
7494 to = { hrefWithoutMd }
7595 hash = { hash }
76- preload = { undefined }
96+ preload = { false }
7797 ref = { undefined }
7898 />
7999 )
You can’t perform that action at this time.
0 commit comments