mirror of
https://github.com/imezx/Warp.git
synced 2025-04-24 23:20:02 +00:00
23 lines
823 B
JavaScript
23 lines
823 B
JavaScript
import { defineComponent, h } from 'vue';
|
|
import { useData, useRoute } from 'vitepress';
|
|
import { contentUpdatedCallbacks } from '../utils';
|
|
const runCbs = () => contentUpdatedCallbacks.forEach((fn) => fn());
|
|
export const Content = defineComponent({
|
|
name: 'VitePressContent',
|
|
props: {
|
|
as: { type: [Object, String], default: 'div' }
|
|
},
|
|
setup(props) {
|
|
const route = useRoute();
|
|
const { site } = useData();
|
|
return () => h(props.as, site.value.contentProps ?? { style: { position: 'relative' } }, [
|
|
route.component
|
|
? h(route.component, {
|
|
onVnodeMounted: runCbs,
|
|
onVnodeUpdated: runCbs,
|
|
onVnodeUnmounted: runCbs
|
|
})
|
|
: '404 Page Not Found'
|
|
]);
|
|
}
|
|
});
|