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

Method _fetchFallbackPage

src/core/fetch/index.js:203–232  ·  view source on GitHub ↗
(path, qs, cb = noop)

Source from the content-addressed store, hash-verified

201 }
202
203 _fetchFallbackPage(path, qs, cb = noop) {
204 const { requestHeaders, fallbackLanguages, loadSidebar } = this.config;
205
206 if (!fallbackLanguages) {
207 return false;
208 }
209
210 const local = path.split('/')[1];
211
212 if (fallbackLanguages.indexOf(local) === -1) {
213 return false;
214 }
215
216 const newPath = this.router.getFile(
217 path.replace(new RegExp(`^/${local}`), '')
218 );
219 const req = request(newPath + qs, true, requestHeaders);
220
221 req.then(
222 (text, opt) =>
223 this._renderMain(
224 text,
225 opt,
226 this._loadSideAndNav(path, qs, loadSidebar, cb)
227 ),
228 () => this._fetch404(path, qs, cb)
229 );
230
231 return true;
232 }
233
234 /**
235 * Load the 404 page

Callers 1

contentFailedToFetchMethod · 0.95

Calls 5

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

Tested by

no test coverage detected