refactor(core): and markdown compiler
This commit is contained in:
parent
30da0d5d46
commit
fe88c154b0
12 changed files with 194 additions and 232 deletions
|
|
@ -1,14 +1,15 @@
|
|||
import { get } from './ajax'
|
||||
import { callHook } from '../init/lifecycle'
|
||||
import { getCurrentRoot } from '../route/util'
|
||||
import { getRoot } from '../route/util'
|
||||
import { noop } from '../util/core'
|
||||
|
||||
export function fetchMixin (Docsify) {
|
||||
let last
|
||||
|
||||
Docsify.prototype._fetch = function (cb) {
|
||||
Docsify.prototype._fetch = function (cb = noop) {
|
||||
const { path } = this.route
|
||||
const { loadNavbar, loadSidebar } = this.config
|
||||
const currentRoot = getCurrentRoot(path)
|
||||
const root = getRoot(path)
|
||||
|
||||
// Abort last request
|
||||
last && last.abort && last.abort()
|
||||
|
|
@ -21,14 +22,14 @@ export function fetchMixin (Docsify) {
|
|||
const fn = result => { this._renderSidebar(result); cb() }
|
||||
|
||||
// Load sidebar
|
||||
get(this.$getFile(currentRoot + loadSidebar))
|
||||
get(this.$getFile(root + loadSidebar))
|
||||
.then(fn, _ => get(loadSidebar).then(fn))
|
||||
},
|
||||
_ => this._renderMain(null))
|
||||
|
||||
// Load nav
|
||||
loadNavbar &&
|
||||
get(this.$getFile(currentRoot + loadNavbar))
|
||||
get(this.$getFile(root + loadNavbar))
|
||||
.then(
|
||||
this._renderNav,
|
||||
_ => get(loadNavbar).then(this._renderNav)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue