Skip to content

Commit 523e77f

Browse files
committed
Added defaultFallbackLanguage config parameter
1 parent 0268594 commit 523e77f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/core/fetch/index.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export function fetchMixin(proto) {
8585
return path404;
8686
};
8787

88-
proto._loadSideAndNav = function(path, qs, loadSidebar, cb) {
88+
proto._loadSideAndNav = function (path, qs, loadSidebar, cb) {
8989
return () => {
9090
if (!loadSidebar) {
9191
return cb();
@@ -101,7 +101,7 @@ export function fetchMixin(proto) {
101101
};
102102
};
103103

104-
proto._fetch = function(cb = noop) {
104+
proto._fetch = function (cb = noop) {
105105
const { path, query } = this.route;
106106
const qs = stringifyQuery(query, ['id']);
107107
const { loadNavbar, requestHeaders, loadSidebar } = this.config;
@@ -139,7 +139,7 @@ export function fetchMixin(proto) {
139139
);
140140
};
141141

142-
proto._fetchCover = function() {
142+
proto._fetchCover = function () {
143143
const { coverpage, requestHeaders } = this.config;
144144
const query = this.route.query;
145145
const root = getParentPath(this.route.path);
@@ -175,7 +175,7 @@ export function fetchMixin(proto) {
175175
}
176176
};
177177

178-
proto.$fetch = function(
178+
proto.$fetch = function (
179179
cb = noop,
180180
$resetEvents = this.$resetEvents.bind(this)
181181
) {
@@ -196,8 +196,8 @@ export function fetchMixin(proto) {
196196
}
197197
};
198198

199-
proto._fetchFallbackPage = function(path, qs, cb = noop) {
200-
const { requestHeaders, fallbackLanguages, loadSidebar } = this.config;
199+
proto._fetchFallbackPage = function (path, qs, cb = noop) {
200+
const { requestHeaders, defaultFallbackLanguage, fallbackLanguages, loadSidebar } = this.config;
201201

202202
if (!fallbackLanguages) {
203203
return false;
@@ -209,7 +209,8 @@ export function fetchMixin(proto) {
209209
return false;
210210
}
211211

212-
const newPath = path.replace(new RegExp(`^/${local}`), '');
212+
const defaultLanguage = defaultFallbackLanguage ? defaultFallbackLanguage : '';
213+
const newPath = path.replace(new RegExp(`^/${local}`), defaultLanguage);
213214
const req = request(newPath + qs, true, requestHeaders);
214215

215216
req.then(
@@ -233,7 +234,7 @@ export function fetchMixin(proto) {
233234
* @returns {Boolean} True if the requested page is not found
234235
* @private
235236
*/
236-
proto._fetch404 = function(path, qs, cb = noop) {
237+
proto._fetch404 = function (path, qs, cb = noop) {
237238
const { loadSidebar, requestHeaders, notFoundPage } = this.config;
238239

239240
const fnLoadSideAndNav = this._loadSideAndNav(path, qs, loadSidebar, cb);

0 commit comments

Comments
 (0)