summaryrefslogtreecommitdiffstats
path: root/lib/generate/page/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/generate/page/index.js')
-rw-r--r--lib/generate/page/index.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/generate/page/index.js b/lib/generate/page/index.js
index fb7c59d..068358c 100644
--- a/lib/generate/page/index.js
+++ b/lib/generate/page/index.js
@@ -21,10 +21,25 @@ util.inherits(Generator, BaseGenerator);
Generator.prototype.loadTemplates = function() {
this.template = swig.compileFile(
- this.plugins.template("page") || path.resolve(this.options.theme, 'templates/page.html')
+ this.plugins.template("page") || path.resolve(this.options.theme, 'templates/page/page.html')
+ );
+ this.summaryTemplate = swig.compileFile(
+ this.plugins.template("page/sumary") || path.resolve(this.options.theme, 'templates/page/summary.html')
);
};
+// Generate table of contents
+Generator.prototype.writeToc = function() {
+ var that = this;
+ var basePath = ".";
+
+ return this._writeTemplate(this.summaryTemplate, {
+ toc: parse.progress(this.options.navigation, "README.md").chapters,
+ basePath: basePath,
+ staticBase: path.join(basePath, "gitbook"),
+ }, path.join(this.options.output, "SUMMARY.html"));
+};
+
Generator.prototype.finish = function() {
var that = this;
var basePath = ".";
@@ -34,6 +49,11 @@ Generator.prototype.finish = function() {
return Q()
+ // Write table of contents
+ .then(function() {
+ return that.writeToc();
+ })
+
// Copy cover
.then(function() {
return that.copyCover();