feat: allow specifying a setup function in Theme

pull/1136/head
Divyansh Singh 3 years ago
parent 7ad269d806
commit 8d101ec66f

@ -2,6 +2,7 @@ import {
App,
createApp as createClientApp,
createSSRApp,
defineComponent,
h,
onMounted,
watch
@ -18,7 +19,7 @@ import { ClientOnly } from './components/ClientOnly'
const NotFound = Theme.NotFound || (() => '404 Not Found')
const VitePressApp = {
const VitePressApp = defineComponent({
name: 'VitePressApp',
setup() {
const { site } = useData()
@ -38,9 +39,11 @@ const VitePressApp = {
// in prod mode, enable intersectionObserver based pre-fetch
usePrefetch()
}
if (Theme.setup) Theme.setup()
return () => h(Theme.Layout)
}
}
})
export function createApp() {
const router = newRouter()

@ -12,4 +12,5 @@ export interface Theme {
Layout: Component
NotFound?: Component
enhanceApp?: (ctx: EnhanceAppContext) => void
setup?: () => void
}

Loading…
Cancel
Save