diff --git a/docs/guide/theme-introduction.md b/docs/guide/theme-introduction.md index 19b062e8..17d8a0b0 100644 --- a/docs/guide/theme-introduction.md +++ b/docs/guide/theme-introduction.md @@ -109,10 +109,9 @@ import DefaultTheme from 'vitepress/theme' export default { ...DefaultTheme, - enhanceApp(ctx) { - DefaultTheme.enhanceApp(ctx) + enhanceApp({ app }) { // register global components - ctx.app.component('MyGlobalComponent', /* ... */) + app.component('MyGlobalComponent', /* ... */) } } ``` diff --git a/docs/guide/using-vue.md b/docs/guide/using-vue.md index 16a4d237..0ae94833 100644 --- a/docs/guide/using-vue.md +++ b/docs/guide/using-vue.md @@ -113,9 +113,8 @@ import DefaultTheme from 'vitepress/theme' export default { ...DefaultTheme, - enhanceApp(ctx) { - DefaultTheme.enhanceApp(ctx) - ctx.app.component('VueClickAwayExample', VueClickAwayExample) + enhanceApp({ app }) { + app.component('VueClickAwayExample', VueClickAwayExample) } } ``` diff --git a/src/client/theme-default/index.ts b/src/client/theme-default/index.ts index fb317104..7b792128 100644 --- a/src/client/theme-default/index.ts +++ b/src/client/theme-default/index.ts @@ -6,13 +6,10 @@ import './styles/components/custom-block.css' import './styles/components/vp-code.css' import './styles/components/vp-doc.css' import './styles/components/vp-sponsor.css' -import 'nprogress/nprogress.css' -import './styles/lib-override/nprogress.css' -import { Theme, inBrowser } from 'vitepress' +import { Theme } from 'vitepress' import Layout from './Layout.vue' import NotFound from './NotFound.vue' -import nprogress from 'nprogress' export { default as VPHomeHero } from './components/VPHomeHero.vue' export { default as VPHomeFeatures } from './components/VPHomeFeatures.vue' @@ -25,30 +22,7 @@ export { default as VPTeamMembers } from './components/VPTeamMembers.vue' const theme: Theme = { Layout, - NotFound, - enhanceApp: ({ router }) => { - if (inBrowser) { - let timeoutId: NodeJS.Timeout - let called = false - - router.onBeforeRouteChange = () => { - timeoutId = setTimeout(() => { - nprogress.start() - called = true - }, 500) - } - - router.onAfterRouteChanged = () => { - if (timeoutId) { - clearTimeout(timeoutId) - } - if (called) { - nprogress.done(true) - called = false - } - } - } - } + NotFound } export default theme diff --git a/theme.d.ts b/theme.d.ts index 3d0fac10..cbb9cdf9 100644 --- a/theme.d.ts +++ b/theme.d.ts @@ -1,6 +1,5 @@ // so that users can do `import DefaultTheme from 'vitepress/theme'` import type { ComponentOptions } from 'vue' -import { EnhanceAppContext } from './dist/client/index.js' export const VPHomeHero: ComponentOptions export const VPHomeFeatures: ComponentOptions @@ -14,7 +13,6 @@ export const VPTeamMembers: ComponentOptions declare const theme: { Layout: ComponentOptions NotFound: ComponentOptions - enhanceApp: EnhanceAppContext } export default theme