feat(cover): add onlyCover option, close #382
This commit is contained in:
parent
f68ddf5af0
commit
b265fdd68a
3 changed files with 20 additions and 5 deletions
|
|
@ -85,6 +85,7 @@ export function fetchMixin (proto) {
|
||||||
path = cover === true ? '_coverpage.md' : cover
|
path = cover === true ? '_coverpage.md' : cover
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.coverEnable = !!path
|
||||||
if (path) {
|
if (path) {
|
||||||
path = this.router.getFile(root + path)
|
path = this.router.getFile(root + path)
|
||||||
this.coverIsHTML = /\.html$/g.test(path)
|
this.coverIsHTML = /\.html$/g.test(path)
|
||||||
|
|
@ -98,12 +99,21 @@ export function fetchMixin (proto) {
|
||||||
}
|
}
|
||||||
|
|
||||||
proto.$fetch = function (cb = noop) {
|
proto.$fetch = function (cb = noop) {
|
||||||
this._fetchCover()
|
const done = () => {
|
||||||
this._fetch(result => {
|
|
||||||
this.$resetEvents()
|
|
||||||
callHook(this, 'doneEach')
|
callHook(this, 'doneEach')
|
||||||
cb()
|
cb()
|
||||||
})
|
}
|
||||||
|
|
||||||
|
this._fetchCover()
|
||||||
|
|
||||||
|
if (this.coverEnable && this.config.onlyCover) {
|
||||||
|
done()
|
||||||
|
} else {
|
||||||
|
this._fetch(result => {
|
||||||
|
this.$resetEvents()
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ function renderMain (html) {
|
||||||
html = 'not found'
|
html = 'not found'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dom.toggleClass(dom.getNode('main'), 'add', 'ready')
|
||||||
this._renderTo('.markdown-section', html)
|
this._renderTo('.markdown-section', html)
|
||||||
// Render sidebar with the TOC
|
// Render sidebar with the TOC
|
||||||
!this.config.loadSidebar && this._renderSidebar()
|
!this.config.loadSidebar && this._renderSidebar()
|
||||||
|
|
|
||||||
|
|
@ -217,12 +217,16 @@ li input[type='checkbox'] {
|
||||||
|
|
||||||
/* main */
|
/* main */
|
||||||
main {
|
main {
|
||||||
display: block;
|
display: none;
|
||||||
position: relative;
|
position: relative;
|
||||||
size: 100vw 100%;
|
size: 100vw 100%;
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main.ready {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.anchor {
|
.anchor {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue