diff --git a/src/client/app/router.ts b/src/client/app/router.ts index bce917765d95..b3b8deeb6f82 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -89,6 +89,15 @@ export function createRouter( if (inBrowser) { nextTick(() => { + let actualPathname = `/${__pageData.relativePath.replace( + /(?:(^|\/)index)?\.md$/, + '$1' + )}` + if (actualPathname !== targetLoc.pathname) { + targetLoc.pathname = actualPathname + history.replaceState(null, '', targetLoc) + } + if (targetLoc.hash && !scrollPosition) { let target: HTMLElement | null = null try {