mirror of https://github.com/vuejs/vitepress
parent
d02ec5e3b4
commit
c4002a8d2e
@ -1,5 +1,3 @@
|
||||
export function usePageData() {
|
||||
return {
|
||||
msg: 'this is page'
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,21 @@
|
||||
import serialized from '@siteData'
|
||||
import { hot } from '@hmr'
|
||||
import { shallowRef, readonly } from 'vue'
|
||||
|
||||
/**
|
||||
* @param {string} data
|
||||
*/
|
||||
const parse = (data) =>
|
||||
__DEV__ ? readonly(JSON.parse(data)) : JSON.parse(data)
|
||||
|
||||
// site data
|
||||
export const siteDataRef = shallowRef(parse(serialized))
|
||||
|
||||
export function useSiteData() {
|
||||
return {
|
||||
msg: 'this is site'
|
||||
}
|
||||
return siteDataRef
|
||||
}
|
||||
|
||||
// hmr
|
||||
hot.accept('/@siteData', (m) => {
|
||||
siteDataRef.value = parse(m.default)
|
||||
})
|
||||
|
@ -1,2 +1,3 @@
|
||||
<div id="app"></div>
|
||||
<script>window.__DEV__ = true</script>
|
||||
<script type="module" src="/@app/index.js"></script>
|
||||
|
@ -1,5 +1,18 @@
|
||||
declare const __DEV__: boolean
|
||||
|
||||
declare module "*.vue" {
|
||||
import { ComponentOptions } from 'vue'
|
||||
const comp: ComponentOptions
|
||||
export default comp
|
||||
}
|
||||
|
||||
declare module "@siteData" {
|
||||
const data: string
|
||||
export default data
|
||||
}
|
||||
|
||||
declare module "@hmr" {
|
||||
export declare const hot: {
|
||||
accept(path: string, cb: (module: any) => void)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue