summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/utils.js2
-rw-r--r--lib/generate/index.js10
-rw-r--r--lib/generate/page/index.js24
-rw-r--r--lib/generate/site/index.js13
4 files changed, 19 insertions, 30 deletions
diff --git a/bin/utils.js b/bin/utils.js
index f736720..3aa4f18 100644
--- a/bin/utils.js
+++ b/bin/utils.js
@@ -83,7 +83,7 @@ function serveDir(dir, port) {
}
function logError(err) {
- console.log(err.message || err);
+ console.log(err.stack || err.message || err);
return Q.reject(err);
};
diff --git a/lib/generate/index.js b/lib/generate/index.js
index c8b98ef..5f44633 100644
--- a/lib/generate/index.js
+++ b/lib/generate/index.js
@@ -127,13 +127,13 @@ var generate = function(options) {
.value()
);
})
+
+ // Finish gneration
+ .then(function() {
+ return generator.finish();
+ });
}
})
-
- // Finish gneration
- .then(function() {
- return generator.finish();
- });
};
module.exports = {
diff --git a/lib/generate/page/index.js b/lib/generate/page/index.js
index 7f730ea..ac815e7 100644
--- a/lib/generate/page/index.js
+++ b/lib/generate/page/index.js
@@ -7,7 +7,7 @@ var hljs = require('highlight.js');
var fs = require("../fs");
var parse = require("../../parse");
-var BaseGenerator = require("../generator");
+var BaseGenerator = require("../site");
// Swig filter: highlight coloration
swig.setFilter('code', function(code, lang) {
@@ -71,30 +71,12 @@ Generator.prototype.finish = function() {
return Q()
// Generate html
.then(function(pages) {
- return that.template({
- title: that.options.title,
- description: that.options.description,
-
- githubAuthor: that.options.github.split("/")[0],
- githubId: that.options.github,
- githubHost: that.options.githubHost,
-
- summary: that.options.summary,
- allNavigation: that.options.navigation,
-
+ return that._writeTemplate(that.template, {
pages: that.pages,
basePath: basePath,
staticBase: path.join(basePath, "gitbook"),
- });
- })
-
- // Write html to index.html
- .then(function(html) {
- return fs.writeFile(
- output,
- html
- );
+ }, output);
})
// Copy assets
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js
index a8626a9..9c3c10c 100644
--- a/lib/generate/site/index.js
+++ b/lib/generate/site/index.js
@@ -87,17 +87,23 @@ Generator.prototype.convertFile = function(content, _input) {
// Generate languages index
Generator.prototype.langsIndex = function(langs) {
+ var that = this;
var basePath = ".";
+
return this._writeTemplate(this.langsTemplate, {
langs: langs.list,
basePath: basePath,
staticBase: path.join(basePath, "gitbook"),
- }, path.join(this.options.output, "index.html"));
+ }, path.join(this.options.output, "index.html"))
+ .then(function() {
+ // Copy assets
+ return that.copyAssets();
+ });
};
-// Symlink index.html and copy assets
-Generator.prototype.finish = function() {
+// Copy assets
+Generator.prototype.copyAssets = function() {
var that = this;
return fs.copy(
@@ -105,5 +111,6 @@ Generator.prototype.finish = function() {
path.join(that.options.output, "gitbook")
);
};
+Generator.prototype.finish = Generator.prototype.copyAssets;
module.exports = Generator; \ No newline at end of file