Skip to content

Commit

Permalink
fix: onlyCover
Browse files Browse the repository at this point in the history
  • Loading branch information
QingWei-Li committed Feb 11, 2018
1 parent 371fbec commit 033be4f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/core/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,17 @@ export function fetchMixin (proto) {
path = cover === true ? '_coverpage' : cover
}

this.coverEnable = !!path
const coverOnly = !!path && this.config.onlyCover
if (path) {
path = this.router.getFile(root + path)
this.coverIsHTML = /\.html$/g.test(path)
get(path + stringifyQuery(query, ['id']), false, requestHeaders).then(
text => this._renderCover(text)
text => this._renderCover(text, coverOnly)
)
} else {
this._renderCover()
this._renderCover(null, coverOnly)
}
return coverOnly
}
}

Expand All @@ -106,9 +107,9 @@ export function fetchMixin (proto) {
cb()
}

this._fetchCover()
const onlyCover = this._fetchCover()

if (this.coverEnable && this.config.onlyCover) {
if (onlyCover) {
done()
} else {
this._fetch(result => {
Expand Down
4 changes: 3 additions & 1 deletion src/core/render/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ export function renderMixin (proto) {
})
}

proto._renderCover = function (text) {
proto._renderCover = function (text, coverOnly) {
const el = dom.getNode('.cover')

dom.toggleClass(dom.getNode('main'), coverOnly ? 'add' : 'remove', 'hidden')
if (!text) {
dom.toggleClass(el, 'remove', 'show')
return
Expand Down
4 changes: 4 additions & 0 deletions src/themes/basic/_layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ main {
z-index: 0;
}

main.hidden {
display: none;
}

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

0 comments on commit 033be4f

Please sign in to comment.