|
|
@ -34,11 +34,22 @@ export function createApp() {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let isInitialPageLoad = inBrowser
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @type string
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
let initialPath
|
|
|
|
|
|
|
|
|
|
|
|
const router = createRouter((route) => {
|
|
|
|
const router = createRouter((route) => {
|
|
|
|
let pagePath = route.path.replace(/\.html$/, '')
|
|
|
|
let pagePath = route.path.replace(/\.html$/, '')
|
|
|
|
if (pagePath.endsWith('/')) {
|
|
|
|
if (pagePath.endsWith('/')) {
|
|
|
|
pagePath += 'index'
|
|
|
|
pagePath += 'index'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isInitialPageLoad) {
|
|
|
|
|
|
|
|
initialPath = pagePath
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (__DEV__) {
|
|
|
|
if (__DEV__) {
|
|
|
|
// awlays force re-fetch content in dev
|
|
|
|
// awlays force re-fetch content in dev
|
|
|
|
pagePath += `.md?t=${Date.now()}`
|
|
|
|
pagePath += `.md?t=${Date.now()}`
|
|
|
@ -46,11 +57,15 @@ export function createApp() {
|
|
|
|
// in production, each .md file is built into a .md.js file following
|
|
|
|
// in production, each .md file is built into a .md.js file following
|
|
|
|
// the path conversion scheme.
|
|
|
|
// the path conversion scheme.
|
|
|
|
// /foo/bar.html -> /js/foo_bar.md.js
|
|
|
|
// /foo/bar.html -> /js/foo_bar.md.js
|
|
|
|
// TODO handle base
|
|
|
|
const useLeanBuild = isInitialPageLoad || initialPath === pagePath
|
|
|
|
pagePath = './' + pagePath.slice(1).replace(/\//g, '_') + '.md.js'
|
|
|
|
pagePath =
|
|
|
|
|
|
|
|
(inBrowser ? __BASE__ + '_assets/' : './') +
|
|
|
|
|
|
|
|
pagePath.slice(1).replace(/\//g, '_') +
|
|
|
|
|
|
|
|
(useLeanBuild ? '.md.lean.js' : '.md.js')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (inBrowser) {
|
|
|
|
if (inBrowser) {
|
|
|
|
|
|
|
|
isInitialPageLoad = false
|
|
|
|
// in browser: native dynamic import
|
|
|
|
// in browser: native dynamic import
|
|
|
|
return import(pagePath).then((page) => {
|
|
|
|
return import(pagePath).then((page) => {
|
|
|
|
if (page.__pageData) {
|
|
|
|
if (page.__pageData) {
|
|
|
|