summaryrefslogtreecommitdiffstats
path: root/lib/output/website.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output/website.js')
-rw-r--r--lib/output/website.js21
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'));
});
};