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.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/generate/page/index.js b/lib/generate/page/index.js
index b089e4d..a489066 100644
--- a/lib/generate/page/index.js
+++ b/lib/generate/page/index.js
@@ -1,3 +1,4 @@
+var _ = require("lodash");
var util = require("util");
var path = require("path");
var Q = require("q");
@@ -58,7 +59,15 @@ Generator.prototype.finish = function() {
var output = path.join(this.options.output, "index.html");
return Q()
+ // Order pages
.then(function() {
+ return _.sortBy(that.pages, function(page) {
+ return page.progress.current.level;
+ });
+ })
+
+ // Generate html
+ .then(function(pages) {
return that.template({
title: that.options.title,
description: that.options.description,
@@ -70,12 +79,14 @@ Generator.prototype.finish = function() {
summary: that.options.summary,
allNavigation: that.options.navigation,
- pages: that.pages,
+ pages: pages,
basePath: basePath,
staticBase: path.join(basePath, "gitbook"),
});
})
+
+ // Write html to index.html
.then(function(html) {
return fs.writeFile(
output,