Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert(#1264): add page load progress bar #1311

Merged
merged 2 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs/guide/theme-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -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', /* ... */)
}
}
```
Expand Down
5 changes: 2 additions & 3 deletions docs/guide/using-vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
```
Expand Down
30 changes: 2 additions & 28 deletions src/client/theme-default/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
2 changes: 0 additions & 2 deletions theme.d.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,7 +13,6 @@ export const VPTeamMembers: ComponentOptions
declare const theme: {
Layout: ComponentOptions
NotFound: ComponentOptions
enhanceApp: EnhanceAppContext
}

export default theme
Expand Down