mengstack-website/.vitepress/theme/Layout.vue

31 lines
767 B
Vue

<script setup>
import DefaultTheme from 'vitepress/theme'
import { useRoute } from 'vitepress'
import { computed, watch, onMounted, onUnmounted } from 'vue'
import Home from './Home.vue'
const route = useRoute()
const isHome = computed(() => route.path === '/' || route.path === '/index.html')
function toggleHomeLayout(val) {
if (typeof document !== 'undefined') {
document.documentElement.classList.toggle('home-layout', val)
}
}
watch(isHome, toggleHomeLayout, { immediate: true })
onMounted(() => toggleHomeLayout(isHome.value))
onUnmounted(() => {
if (typeof document !== 'undefined') {
document.documentElement.classList.remove('home-layout')
}
})
</script>
<template>
<Home v-if="isHome" />
<DefaultTheme.Layout v-else />
</template>