Skip to content

Commit bd5f879

Browse files
committed
feat: The timing of the doneEach hook call for the cover
The `doneEach` hook function for the cover should be called after the cover page HTML has been appended to the DOM.
1 parent 0070e26 commit bd5f879

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/core/fetch/index.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export function Fetch(Base) {
150150
}
151151
}
152152

153-
_fetchCover() {
153+
_fetchCover(cb = noop) {
154154
const { coverpage, requestHeaders } = this.config;
155155
const query = this.route.query;
156156
const root = getParentPath(this.route.path);
@@ -174,13 +174,17 @@ export function Fetch(Base) {
174174
path = this.router.getFile(root + path);
175175
this.coverIsHTML = /\.html$/g.test(path);
176176
get(path + stringifyQuery(query, ['id']), false, requestHeaders).then(
177-
text => this._renderCover(text, coverOnly)
177+
text => {
178+
this._renderCover(text, coverOnly);
179+
cb(coverOnly);
180+
}
178181
);
179182
} else {
180183
this._renderCover(null, coverOnly);
184+
cb(coverOnly);
181185
}
182-
183-
return coverOnly;
186+
} else {
187+
cb(false);
184188
}
185189
}
186190

@@ -190,16 +194,16 @@ export function Fetch(Base) {
190194
cb();
191195
};
192196

193-
const onlyCover = this._fetchCover();
194-
195-
if (onlyCover) {
196-
done();
197-
} else {
198-
this._fetch(() => {
199-
onNavigate();
197+
this._fetchCover(onlyCover => {
198+
if (onlyCover) {
200199
done();
201-
});
202-
}
200+
} else {
201+
this._fetch(() => {
202+
onNavigate();
203+
done();
204+
});
205+
}
206+
});
203207
}
204208

205209
_fetchFallbackPage(path, qs, cb = noop) {

0 commit comments

Comments
 (0)