File tree 3 files changed +16
-4
lines changed
3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change
1
+ import { ref , onMounted , defineComponent } from 'vue'
2
+
3
+ export const ClientOnly = defineComponent ( {
4
+ setup ( _ , { slots } ) {
5
+ const show = ref ( false )
6
+ onMounted ( ( ) => {
7
+ show . value = true
8
+ } )
9
+ return ( ) => ( show . value && slots . default ? slots . default ( ) : null )
10
+ }
11
+ } )
Original file line number Diff line number Diff line change 1
- import { h } from 'vue'
1
+ import { defineComponent , h } from 'vue'
2
2
import { useRoute } from '../router'
3
3
4
- export const Content = {
4
+ export const Content = defineComponent ( {
5
5
name : 'VitePressContent' ,
6
6
setup ( ) {
7
7
const route = useRoute ( )
8
8
return ( ) => ( route . component ? h ( route . component ) : null )
9
9
}
10
- }
10
+ } )
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { SiteDataRef } from './composables/siteData'
4
4
import { PageDataRef } from './composables/pageData'
5
5
import { Content } from './components/Content'
6
6
import Debug from './components/Debug.vue'
7
+ import { ClientOnly } from './components/ClientOnly'
7
8
8
9
export function mixinGlobalComputed (
9
10
app : App ,
@@ -68,6 +69,6 @@ export function mixinGlobalComponents(app: App) {
68
69
const isProd = process . env . NODE_ENV === 'production'
69
70
70
71
app . component ( 'Content' , Content )
71
-
72
+ app . component ( 'ClientOnly' , ClientOnly )
72
73
app . component ( 'Debug' , isProd ? ( ) => null : Debug )
73
74
}
You can’t perform that action at this time.
0 commit comments