mirror of
https://github.com/wahyd4/vuepress.git
synced 2026-08-16 08:45:51 +10:00
39 lines
660 B
JavaScript
39 lines
660 B
JavaScript
import Vue from 'vue'
|
|
import { siteData } from './.temp/siteData'
|
|
import { findPageForPath } from './util'
|
|
|
|
function prepare (siteData) {
|
|
siteData.pages.forEach(page => {
|
|
if (!page.frontmatter) {
|
|
page.frontmatter = {}
|
|
}
|
|
})
|
|
Object.freeze(siteData)
|
|
}
|
|
|
|
prepare(siteData)
|
|
const store = new Vue({
|
|
data: { siteData }
|
|
})
|
|
|
|
if (module.hot) {
|
|
module.hot.accept('./.temp/siteData', () => {
|
|
prepare(siteData)
|
|
store.siteData = siteData
|
|
})
|
|
}
|
|
|
|
export default {
|
|
computed: {
|
|
$site () {
|
|
return store.siteData
|
|
},
|
|
$page () {
|
|
return findPageForPath(
|
|
this.$site.pages,
|
|
this.$route.path
|
|
)
|
|
}
|
|
}
|
|
}
|