Skip to content

Commit 033be4f

Browse files
committed
fix: onlyCover
1 parent 371fbec commit 033be4f

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

Diff for: src/core/fetch/index.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,17 @@ export function fetchMixin (proto) {
8787
path = cover === true ? '_coverpage' : cover
8888
}
8989

90-
this.coverEnable = !!path
90+
const coverOnly = !!path && this.config.onlyCover
9191
if (path) {
9292
path = this.router.getFile(root + path)
9393
this.coverIsHTML = /\.html$/g.test(path)
9494
get(path + stringifyQuery(query, ['id']), false, requestHeaders).then(
95-
text => this._renderCover(text)
95+
text => this._renderCover(text, coverOnly)
9696
)
9797
} else {
98-
this._renderCover()
98+
this._renderCover(null, coverOnly)
9999
}
100+
return coverOnly
100101
}
101102
}
102103

@@ -106,9 +107,9 @@ export function fetchMixin (proto) {
106107
cb()
107108
}
108109

109-
this._fetchCover()
110+
const onlyCover = this._fetchCover()
110111

111-
if (this.coverEnable && this.config.onlyCover) {
112+
if (onlyCover) {
112113
done()
113114
} else {
114115
this._fetch(result => {

Diff for: src/core/render/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@ export function renderMixin (proto) {
134134
})
135135
}
136136

137-
proto._renderCover = function (text) {
137+
proto._renderCover = function (text, coverOnly) {
138138
const el = dom.getNode('.cover')
139+
140+
dom.toggleClass(dom.getNode('main'), coverOnly ? 'add' : 'remove', 'hidden')
139141
if (!text) {
140142
dom.toggleClass(el, 'remove', 'show')
141143
return

Diff for: src/themes/basic/_layout.css

+4
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ main {
223223
z-index: 0;
224224
}
225225

226+
main.hidden {
227+
display: none;
228+
}
229+
226230
.anchor {
227231
display: inline-block;
228232
text-decoration: none;

0 commit comments

Comments
 (0)