From 3c3ee0d7aeb1f572648b93a0575be34a4badcfab Mon Sep 17 00:00:00 2001 From: DIG for IT! <44548380+digforit@users.noreply.github.com> Date: Sat, 31 Aug 2019 14:13:35 +0200 Subject: [PATCH] Update index.js + Added 'defaultFallbackLanguage' parameter to avoid the need of having the default language in root folder. --- src/core/fetch/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/fetch/index.js b/src/core/fetch/index.js index 17208df69..e5b78fcd1 100644 --- a/src/core/fetch/index.js +++ b/src/core/fetch/index.js @@ -163,7 +163,7 @@ export function fetchMixin(proto) { } proto._fetchFallbackPage = function (path, qs, cb = noop) { - const {requestHeaders, fallbackLanguages, loadSidebar} = this.config + const {requestHeaders, defaultFallbackLanguage, fallbackLanguages, loadSidebar} = this.config if (!fallbackLanguages) { return false @@ -174,7 +174,14 @@ export function fetchMixin(proto) { if (fallbackLanguages.indexOf(local) === -1) { return false } - const newPath = path.replace(new RegExp(`^/${local}`), '') + + var defaultLanguage = ''; + if (defaultFallbackLanguage) + { + defaultLanguage = defaultFallbackLanguage; + } + + const newPath = path.replace(new RegExp(`^/${local}`), defaultLanguage) const req = request(newPath + qs, true, requestHeaders) req.then(