Disable directoryIndex for ebook generation

This commit is contained in:
Samy Pessé
2016-02-21 18:08:36 +01:00
parent 360381dd9f
commit 5f058f2ceb
3 changed files with 9 additions and 4 deletions
+2 -2
View File
@@ -19,7 +19,7 @@ function Output(book, opts) {
_.bindAll(this);
this.opts = _.defaults(opts || {}, {
directoryIndex: true
});
this.book = book;
@@ -222,7 +222,7 @@ Output.prototype.outputPath = function(filename, ext) {
Output.prototype.outputUrl = function(filename, ext) {
var href = this.outputPath(filename, ext);
if (path.basename(href) == 'index.html') {
if (path.basename(href) == 'index.html' && this.opts.directoryIndex) {
href = path.dirname(href) + '/';
}
+3
View File
@@ -10,6 +10,9 @@ var assetsInliner = require('./assets-inliner');
function _EbookOutput() {
WebsiteOutput.apply(this, arguments);
// ebook-convert does not support link like "./"
this.opts.directoryIndex = false;
}
util.inherits(_EbookOutput, WebsiteOutput);
+4 -2
View File
@@ -103,8 +103,10 @@ WebsiteOutput.prototype.prepare = function() {
// Relase path to an asset
that.env.addFilter('resolveAsset', function(href) {
href = path.join('/gitbook', href);
return that.resolveForPage(this.ctx.file.path, href);
href = path.join('gitbook', href);
if (!this.ctx.file) return href;
return that.resolveForPage(this.ctx.file.path, '/' + href);
});
})