diff options
Diffstat (limited to 'lib/output')
-rw-r--r-- | lib/output/base.js | 19 | ||||
-rw-r--r-- | lib/output/json.js | 7 |
2 files changed, 15 insertions, 11 deletions
diff --git a/lib/output/base.js b/lib/output/base.js index 6ac3d7e..987179a 100644 --- a/lib/output/base.js +++ b/lib/output/base.js @@ -5,6 +5,7 @@ var path = require('path'); var Promise = require('../utils/promise'); var PluginsManager = require('../plugins'); var TemplateEngine = require('../template'); +var gitbook = require('../gitbook'); /* Output is like a stream interface for a parsed book @@ -117,6 +118,11 @@ Output.prototype.onAsset = function(filename) { }; +// Finish the generation +Output.prototype.finish = function() { + +}; + // Resolve an HTML link Output.prototype.onRelativeLink = function(currentPage, href) { var to = this.book.getPage(href); @@ -146,13 +152,16 @@ Output.prototype.onResolveTemplate = function(from, to) { return path.resolve(path.dirname(from), to); }; -// Finish the generation -Output.prototype.finish = function() { - -}; -Output.createMixin = function(def) { +// ---- Utilities ---- +Output.prototype.getPageContext = function(page) { + return _.extend( + page.getContext(), + gitbook.getContext(), + this.book.getContext(), + this.book.summary.getContext() + ); }; module.exports = Output; diff --git a/lib/output/json.js b/lib/output/json.js index c4317c9..4fb3bbf 100644 --- a/lib/output/json.js +++ b/lib/output/json.js @@ -1,5 +1,4 @@ var _ = require('lodash'); -var gitbook = require('../gitbook'); var conrefsLoader = require('./conrefs'); var JSONOutput = conrefsLoader(); @@ -18,11 +17,7 @@ JSONOutput.prototype.onPage = function(page) { // Write as json .then(function() { - var json = _.extend( - page.getContext(), - gitbook.getContext(), - that.book.getContext() - ); + var json = that.getPageContext(page); return that.writeFile( page.withExtension('.json'), |