diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-21 11:33:33 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-21 11:33:33 +0100 |
commit | be2da0fab1c467f84c33517950d67da3c9b5768d (patch) | |
tree | d5840c8c1cb97bd8f8a8a192c545ffb4577a8e3b /lib/book.js | |
parent | 0da50819d663b94bb85ffcaae4231a635921431c (diff) | |
download | gitbook-be2da0fab1c467f84c33517950d67da3c9b5768d.zip gitbook-be2da0fab1c467f84c33517950d67da3c9b5768d.tar.gz gitbook-be2da0fab1c467f84c33517950d67da3c9b5768d.tar.bz2 |
Fix json template preparation
Diffstat (limited to 'lib/book.js')
-rw-r--r-- | lib/book.js | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/book.js b/lib/book.js index 41b1d1a..27a609c 100644 --- a/lib/book.js +++ b/lib/book.js @@ -5,6 +5,7 @@ var path = require("path"); var fs = require("./utils/fs"); var parseNavigation = require("./utils/navigation"); var parseProgress = require("./utils/progress"); +var pageUtil = require("./utils/page"); var Configuration = require("./configuration"); var TemplateEngine = require("./template"); @@ -48,7 +49,7 @@ var Book = function(root, options, parent) { this.files = []; // List of plugins - this.plugins = {}; + this.plugins = []; // Readme file this.readmeFile = "README.md"; @@ -134,7 +135,7 @@ Book.prototype.generate = function(generator) { if (!Generator) throw "Generator '"+that.options.generator+"' doesn't exist"; generator = new Generator(that); - return generator.load(); + return generator.prepare(); }) // Generate content @@ -309,7 +310,25 @@ Book.prototype.parsePage = function(filename) { return filetype.parser.page(content); }) .then(function(page) { + // Type of parser used + page.type = filetype.name; + + // Path relative to book + page.path = filename; + + // Path absolute in the system + page.rawPath = path.resolve(that.root, filename); + + // Progress in the book page.progress = parseProgress(that.navigation, filename); + + // Content sections + page.sections = pageUtil.normalize(page.sections, { + navigation: that.navigation, + base: path.dirname(filename) || './', + output: path.dirname(filename) || './' + }); + return page; }); }; |