diff --git a/src/components/DocsLayout.tsx b/src/components/DocsLayout.tsx
index 5f66bc75f..4b48d6128 100644
--- a/src/components/DocsLayout.tsx
+++ b/src/components/DocsLayout.tsx
@@ -848,6 +848,8 @@ export function DocsLayout({
})
}, [groupInitialOpenState])
+ const libraryHomePath = `/${libraryId}/${version}`
+
const menuItems = menuConfig.map((group, i) => {
const groupKey = `${i}:${String(group.label)}`
@@ -919,8 +921,7 @@ export function DocsLayout({
) : isHomeLink ? (
{
detailsRef.current.removeAttribute('open')
}}
diff --git a/src/components/markdown/MarkdownLink.tsx b/src/components/markdown/MarkdownLink.tsx
index 43942fea3..0ae1996ef 100644
--- a/src/components/markdown/MarkdownLink.tsx
+++ b/src/components/markdown/MarkdownLink.tsx
@@ -29,6 +29,24 @@ function isRoutableInternalLink(link: string) {
)
}
+function normalizeRoutableInternalPathname(pathname: string) {
+ const routerFrameworkMatch = pathname.match(
+ /^\/router\/([^/]+)\/docs\/framework\/[^/]+\/(.+)$/,
+ )
+
+ if (!routerFrameworkMatch) {
+ return pathname
+ }
+
+ const [, version, docsPath] = routerFrameworkMatch
+
+ if (!version || !docsPath || docsPath.startsWith('examples/')) {
+ return pathname
+ }
+
+ return `/router/${version}/docs/${docsPath}`
+}
+
export function MarkdownLink({
href: hrefProp,
...rest
@@ -37,14 +55,16 @@ export function MarkdownLink({
if (isRoutableInternalLink(href)) {
const [hrefWithoutHash, hash] = href.split('#')
- const hrefWithoutMd = hrefWithoutHash.replace('.md', '')
+ const hrefWithoutMd = normalizeRoutableInternalPathname(
+ hrefWithoutHash.replace('.md', ''),
+ )
return (
)
@@ -73,7 +93,7 @@ export function MarkdownLink({
unsafeRelative="path"
to={hrefWithoutMd}
hash={hash}
- preload={undefined}
+ preload={false}
ref={undefined}
/>
)