File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed
Expand file tree Collapse file tree 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'
22import { useRoute } from '../router'
33
4- export const Content = {
4+ export const Content = defineComponent ( {
55 name : 'VitePressContent' ,
66 setup ( ) {
77 const route = useRoute ( )
88 return ( ) => ( route . component ? h ( route . component ) : null )
99 }
10- }
10+ } )
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { SiteDataRef } from './composables/siteData'
44import { PageDataRef } from './composables/pageData'
55import { Content } from './components/Content'
66import Debug from './components/Debug.vue'
7+ import { ClientOnly } from './components/ClientOnly'
78
89export function mixinGlobalComputed (
910 app : App ,
@@ -68,6 +69,6 @@ export function mixinGlobalComponents(app: App) {
6869 const isProd = process . env . NODE_ENV === 'production'
6970
7071 app . component ( 'Content' , Content )
71-
72+ app . component ( 'ClientOnly' , ClientOnly )
7273 app . component ( 'Debug' , isProd ? ( ) => null : Debug )
7374}
You can’t perform that action at this time.
0 commit comments