mirror of https://github.com/vuejs/vitepress
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
447 B
24 lines
447 B
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
|
|
const siteDataRef = shallowRef(parse(serialized))
|
|
|
|
export function useSiteData() {
|
|
return siteDataRef
|
|
}
|
|
|
|
// hmr
|
|
if (__DEV__) {
|
|
hot.accept('/@siteData', (m) => {
|
|
siteDataRef.value = parse(m.default)
|
|
})
|
|
}
|