mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
Fix parsing of multilingual books
This commit is contained in:
+1
-1
@@ -248,7 +248,7 @@ Book.createFromParent = function createFromParent(parent, language) {
|
||||
logger: parent.getLogger(),
|
||||
ignore: Ignore().add(ignore),
|
||||
language: language,
|
||||
fs: FS.reduceScope(parent.getFS(), language)
|
||||
fs: FS.reduceScope(parent.getContentFS(), language)
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
+2
-1
@@ -33,7 +33,8 @@ FS.prototype.getRoot = function() {
|
||||
*/
|
||||
FS.prototype.isInScope = function(filename) {
|
||||
var rootPath = this.getRoot();
|
||||
filename = path.resolve(rootPath, filename);
|
||||
filename = path.join(rootPath, filename);
|
||||
|
||||
return PathUtil.isInRoot(rootPath, filename);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
var Immutable = require('immutable');
|
||||
|
||||
var File = require('./file');
|
||||
var Language = require('./language');
|
||||
|
||||
var Languages = Immutable.Record({
|
||||
file: File(),
|
||||
@@ -34,4 +35,29 @@ Languages.prototype.getLanguage = function(lang) {
|
||||
return this.getList().get(lang);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Create a languages list from a JS object
|
||||
|
||||
@param {File}
|
||||
@param {Array}
|
||||
@return {Language}
|
||||
*/
|
||||
Languages.createFromList = function(file, langs) {
|
||||
var list = Immutable.OrderedMap();
|
||||
|
||||
langs.forEach(function(lang) {
|
||||
lang = Language({
|
||||
title: lang.title,
|
||||
path: lang.path
|
||||
});
|
||||
list = list.set(lang.getID(), lang);
|
||||
});
|
||||
|
||||
return Languages({
|
||||
file: file,
|
||||
list: list
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = Languages;
|
||||
|
||||
Reference in New Issue
Block a user