MCPcopy
hub / github.com/docsifyjs/docsify / _fetch404

Method _fetch404

src/core/fetch/index.js:242–258  ·  view source on GitHub ↗

* Load the 404 page * @param {String} path URL to be loaded * @param {*} qs TODO: define * @param {Function} cb Callback * @returns {Boolean} True if the requested page is not found * @private

(path, qs, cb = noop)

Source from the content-addressed store, hash-verified

240 * @private
241 */
242 _fetch404(path, qs, cb = noop) {
243 const { loadSidebar, requestHeaders, notFoundPage } = this.config;
244
245 const fnLoadSideAndNav = this._loadSideAndNav(path, qs, loadSidebar, cb);
246 if (notFoundPage) {
247 const path404 = get404Path(path, this.config);
248
249 request(this.router.getFile(path404), true, requestHeaders).then(
250 (text, opt) => this._renderMain(text, opt, fnLoadSideAndNav),
251 () => this._renderMain(null, {}, fnLoadSideAndNav)
252 );
253 return true;
254 }
255
256 this._renderMain(null, {}, fnLoadSideAndNav);
257 return false;
258 }
259
260 initFetch() {
261 const { loadSidebar } = this.config;

Callers 2

contentFailedToFetchMethod · 0.95
_fetchFallbackPageMethod · 0.95

Calls 5

_loadSideAndNavMethod · 0.95
get404PathFunction · 0.85
requestFunction · 0.85
getFileMethod · 0.80
_renderMainMethod · 0.80

Tested by

no test coverage detected