diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-24 12:56:26 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-24 12:56:26 +0100 |
commit | bd73c7978743329f893c1125d1645b8aa24eb7d8 (patch) | |
tree | 63a311016951e500478a39d97c30e9473f95854d /lib/output/website.js | |
parent | b244d506bd49526abbcfe84e2175b3410bbabb8c (diff) | |
download | gitbook-bd73c7978743329f893c1125d1645b8aa24eb7d8.zip gitbook-bd73c7978743329f893c1125d1645b8aa24eb7d8.tar.gz gitbook-bd73c7978743329f893c1125d1645b8aa24eb7d8.tar.bz2 |
Don't copy assets for each language book, but only for main book
Diffstat (limited to 'lib/output/website.js')
-rw-r--r-- | lib/output/website.js | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/output/website.js b/lib/output/website.js index d480550..6961a28 100644 --- a/lib/output/website.js +++ b/lib/output/website.js @@ -5,6 +5,7 @@ var nunjucks = require('nunjucks'); var I18n = require('i18n-t'); var Promise = require('../utils/promise'); +var location = require('../utils/location'); var fs = require('../utils/fs'); var defaultFilters = require('../template/filters'); var conrefsLoader = require('./conrefs'); @@ -106,25 +107,36 @@ WebsiteOutput.prototype.prepare = function() { // Transform an absolute path into a relative path // using this.ctx.page.path that.env.addFilter('resolveFile', function(href) { - return that.resolveForPage(this.ctx.file.path, href); + return location.normalize(that.resolveForPage(this.ctx.file.path, href)); }); // Transform a '.md' into a '.html' (README -> index) that.env.addFilter('contentURL', function(s) { - return that.outputUrl(s); + return location.normalize(that.outputUrl(s)); }); // Relase path to an asset that.env.addFilter('resolveAsset', function(href) { href = path.join('gitbook', href); - if (!this.ctx.file) return href; - return that.resolveForPage(this.ctx.file.path, '/' + href); + // Resolve for current file + if (this.ctx.file) { + href = that.resolveForPage(this.ctx.file.path, '/' + href); + } + + // Use assets from parent + if (that.book.isLanguageBook()) { + href = path.join('../', href); + } + + return location.normalize(href); }); }) // Copy assets from themes before copying files from book .then(function() { + if (that.book.isLanguageBook()) return; + return Promise.serie([ // Assets from the book are already copied // The order is reversed from the template's one @@ -196,6 +208,7 @@ WebsiteOutput.prototype.finish = function() { // Copy assets from plugins .then(function() { + if (that.book.isLanguageBook()) return; return that.plugins.copyResources(that.name, that.resolve('gitbook')); }); }; |