路径映射问题
#4819
Replies: 1 comment 1 reply
-
Inside import DefaultTheme from 'vitepress/theme'
import type { Theme } from 'vitepress'
const hashToRoute = {
'/foo/bar': '/foo/bar'
}
export default {
extends: DefaultTheme,
enhanceApp({ router }) {
router.onBeforeRouteChange = (to) => {
const u = new URL(to, 'http://a.com')
if (u.pathname === '/') {
const route = hashToRoute[u.hash.slice(1)]
if (route) window.location.href = route
}
}
}
} satisfies Theme See #4160 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
我正在迁移老的文档框架 docsify 到 vitepress,但是路径的路由格式有很多差异。这会导致很多现有文档链接失效。
有没有办法可以自动将
路由到
确保一些现有的老链接也能正常访问到对应文档。
比如可以配置一个 url 映射的 map 集合,实现自动跳转。
Beta Was this translation helpful? Give feedback.
All reactions