Skip to content

Commit

Permalink
feat(cover): add onlyCover option, close #382
Browse files Browse the repository at this point in the history
  • Loading branch information
QingWei-Li committed Feb 11, 2018
1 parent f68ddf5 commit b265fdd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
18 changes: 14 additions & 4 deletions src/core/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export function fetchMixin (proto) {
path = cover === true ? '_coverpage.md' : cover
}

this.coverEnable = !!path
if (path) {
path = this.router.getFile(root + path)
this.coverIsHTML = /\.html$/g.test(path)
Expand All @@ -98,12 +99,21 @@ export function fetchMixin (proto) {
}

proto.$fetch = function (cb = noop) {
this._fetchCover()
this._fetch(result => {
this.$resetEvents()
const done = () => {
callHook(this, 'doneEach')
cb()
})
}

this._fetchCover()

if (this.coverEnable && this.config.onlyCover) {
done()
} else {
this._fetch(result => {
this.$resetEvents()
done()
})
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/core/render/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function renderMain (html) {
html = 'not found'
}

dom.toggleClass(dom.getNode('main'), 'add', 'ready')
this._renderTo('.markdown-section', html)
// Render sidebar with the TOC
!this.config.loadSidebar && this._renderSidebar()
Expand Down
6 changes: 5 additions & 1 deletion src/themes/basic/_layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,16 @@ li input[type='checkbox'] {

/* main */
main {
display: block;
display: none;
position: relative;
size: 100vw 100%;
z-index: 0;
}

main.ready {
display: block;
}

.anchor {
display: inline-block;
text-decoration: none;
Expand Down

0 comments on commit b265fdd

Please sign in to comment.