mirror of https://github.com/vuejs/vitepress
parent
d02ec5e3b4
commit
c4002a8d2e
@ -1,5 +1,3 @@
|
|||||||
export function usePageData() {
|
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() {
|
export function useSiteData() {
|
||||||
return {
|
return siteDataRef
|
||||||
msg: 'this is site'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// hmr
|
||||||
|
hot.accept('/@siteData', (m) => {
|
||||||
|
siteDataRef.value = parse(m.default)
|
||||||
|
})
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
<script>window.__DEV__ = true</script>
|
||||||
<script type="module" src="/@app/index.js"></script>
|
<script type="module" src="/@app/index.js"></script>
|
||||||
|
@ -1,5 +1,18 @@
|
|||||||
|
declare const __DEV__: boolean
|
||||||
|
|
||||||
declare module "*.vue" {
|
declare module "*.vue" {
|
||||||
import { ComponentOptions } from 'vue'
|
import { ComponentOptions } from 'vue'
|
||||||
const comp: ComponentOptions
|
const comp: ComponentOptions
|
||||||
export default comp
|
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