summaryrefslogtreecommitdiffstats
path: root/lib/output/base.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output/base.js')
-rw-r--r--lib/output/base.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/output/base.js b/lib/output/base.js
index a6cfa0d..7b527da 100644
--- a/lib/output/base.js
+++ b/lib/output/base.js
@@ -4,6 +4,7 @@ var path = require('path');
var Promise = require('../utils/promise');
var pathUtil = require('../utils/path');
+var location = require('../utils/location');
var PluginsManager = require('../plugins');
var TemplateEngine = require('../template');
var gitbook = require('../gitbook');
@@ -130,7 +131,9 @@ Output.prototype.finish = function() {
// Resolve an HTML link
Output.prototype.onRelativeLink = function(currentPage, href) {
var to = this.book.getPage(href);
- if (to) return this.outputPath(to.path);
+
+ // Replace by an .html link
+ if (to) href = this.outputUrl(to.path);
return href;
};
@@ -189,4 +192,16 @@ Output.prototype.outputPath = function(filename, ext) {
return output;
};
+// Filename for output
+// /test/index.html -> /test/
+Output.prototype.outputUrl = function(filename, ext) {
+ var href = this.outputPath(filename, ext);
+
+ if (path.basename(href) == 'index.html') {
+ href = path.dirname(href) + '/';
+ }
+
+ return location.normalize(href);
+};
+
module.exports = Output;