summaryrefslogtreecommitdiffstats
path: root/lib/generate/site/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/generate/site/index.js')
-rw-r--r--lib/generate/site/index.js23
1 files changed, 7 insertions, 16 deletions
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js
index da65152..b59c01c 100644
--- a/lib/generate/site/index.js
+++ b/lib/generate/site/index.js
@@ -2,26 +2,16 @@ var util = require("util");
var path = require("path");
var Q = require("q");
var _ = require("lodash");
-var swig = require('swig');
+var swig = require("../template");
var fs = require("../fs");
var parse = require("../../parse");
var BaseGenerator = require("../generator");
-
+var links = require("../../utils/links");
var indexer = require('./search_indexer');
var Manifest = require('../manifest');
-// Swig filter for returning the count of lines in a code section
-swig.setFilter('lines', function(content) {
- return content.split('\n').length;
-});
-// Swig filter for returning a link to the associated html file of a markdown file
-swig.setFilter('mdLink', function(link) {
- var link = link.replace(".md", ".html");
- if (link == "README.html") link = "index.html";
- return link;
-});
var Generator = function() {
BaseGenerator.apply(this, arguments);
@@ -63,7 +53,6 @@ Generator.prototype._writeTemplate = function(tpl, options, output, interpolate)
var that = this;
interpolate = interpolate || _.identity;
-
return Q()
.then(function(sections) {
return tpl(_.extend({
@@ -163,7 +152,7 @@ Generator.prototype.convertFile = function(content, _input) {
content: page.sections,
basePath: basePath,
- staticBase: path.join(basePath, "gitbook"),
+ staticBase: links.join(basePath, "gitbook"),
}, output, function(html) {
page.content = html;
@@ -199,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");
})
@@ -238,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);