summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-04-04 15:53:30 -0700
committerSamy Pessé <samypesse@gmail.com>2014-04-04 15:53:30 -0700
commite34e65813ccb05ae29b7d47f9258663898315de9 (patch)
tree2455436fcb0d4ad23aba5a1cc6ad79026d41bf93
parent63f946ced9e4a13752ee7fc9fc3359c99ef8fb90 (diff)
downloadgitbook-e34e65813ccb05ae29b7d47f9258663898315de9.zip
gitbook-e34e65813ccb05ae29b7d47f9258663898315de9.tar.gz
gitbook-e34e65813ccb05ae29b7d47f9258663898315de9.tar.bz2
Fix pages order in page generator
-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,