diff options
Diffstat (limited to 'lib/generate')
-rw-r--r-- | lib/generate/generator.js | 22 | ||||
-rw-r--r-- | lib/generate/index.js | 4 | ||||
-rw-r--r-- | lib/generate/page/index.js | 5 | ||||
-rw-r--r-- | lib/generate/site/index.js | 6 |
4 files changed, 34 insertions, 3 deletions
diff --git a/lib/generate/generator.js b/lib/generate/generator.js index 2c4cb44..18d6066 100644 --- a/lib/generate/generator.js +++ b/lib/generate/generator.js @@ -45,6 +45,28 @@ BaseGenerator.prototype.transferFolder = function(input) { ); }; +BaseGenerator.prototype.copyCover = function() { + var that = this; + + return Q.all([ + fs.copy(path.join(this.options.input, "cover.jpg"), path.join(this.options.output, "cover.jpg")), + fs.copy(path.join(this.options.input, "cover_small.jpg"), path.join(this.options.output, "cover_small.jpg")) + ]) + .fail(function() { + // If orignally from multi-lang, try copy from originalInput + if (!that.options.originalInput) return; + + return Q.all([ + fs.copy(path.join(that.options.originalInput, "cover.jpg"), path.join(that.options.output, "cover.jpg")), + fs.copy(path.join(that.options.originalInput, "cover_small.jpg"), path.join(that.options.output, "cover_small.jpg")) + ]); + }) + .fail(function(err) { + console.log(err); + return Q(); + }); +}; + BaseGenerator.prototype.langsIndex = function(langs) { return Q.reject(new Error("Langs index is not supported in this generator")); }; diff --git a/lib/generate/index.js b/lib/generate/index.js index ede2c60..740f6ba 100644 --- a/lib/generate/index.js +++ b/lib/generate/index.js @@ -161,7 +161,9 @@ var generateMultiLang = function(options) { return prev.then(function() { return generate(_.extend({}, options, { input: path.join(options.input, entry.path), - output: path.join(options.output, entry.path) + output: path.join(options.output, entry.path), + originalInput: options.input, + originalOutput: options.output })); }) }, Q()); diff --git a/lib/generate/page/index.js b/lib/generate/page/index.js index 68fd334..bd9b233 100644 --- a/lib/generate/page/index.js +++ b/lib/generate/page/index.js @@ -75,6 +75,11 @@ Generator.prototype.finish = function() { }, output); }) + // Copy cover + .then(function() { + return that.copyCover(); + }) + // Copy assets .then(function() { return fs.copy( diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js index 51f8cae..b59c01c 100644 --- a/lib/generate/site/index.js +++ b/lib/generate/site/index.js @@ -188,7 +188,7 @@ Generator.prototype.copyAssets = function() { path.join(that.options.output, "gitbook") ) - // Add to cach manifest + // Add to cache manifest .then(function() { return that.manifest.addFolder(path.join(that.options.output, "gitbook"), "gitbook"); }) @@ -227,7 +227,9 @@ Generator.prototype.writeCacheManifest = function() { }; Generator.prototype.finish = function() { - var deferred = this.copyAssets().then(this.writeSearchIndex); + var deferred = this.copyAssets() + .then(this.copyCover) + .then(this.writeSearchIndex); if (this.options.cache !== false) { deferred = deferred.then(this.writeCacheManifest); |