summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/book.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/book.js b/lib/book.js
index 797783b..dcf0a33 100644
--- a/lib/book.js
+++ b/lib/book.js
@@ -16,7 +16,15 @@ var Plugin = require("./plugin");
var generators = require("./generators");
-var Book = function(root, options, parent) {
+var Book = function(root, context, parent) {
+ this.context = _.defaults(context || {}, {
+ // Extend book configuration
+ config: {},
+
+ // Log function
+ log: console.log.bind(console)
+ })
+
// Root folder of the book
this.root = root;
@@ -24,7 +32,7 @@ var Book = function(root, options, parent) {
this.parent = parent;
// Configuration
- this.config = new Configuration(this, options);
+ this.config = new Configuration(this, this.context.config);
Object.defineProperty(this, "options", {
get: function () {
return this.config.options;
@@ -85,9 +93,11 @@ Book.prototype.parse = function() {
that.books = _.map(that.langs, function(lang) {
return new Book(
path.join(that.root, lang.path),
- _.extend({}, that.options, {
- 'output': path.join(that.options.output, lang.path),
- 'lang': lang.lang
+ _.merge({}, that.context, {
+ config: _.extend({}, that.options, {
+ 'output': path.join(that.options.output, lang.path),
+ 'lang': lang.lang
+ })
}),
that
)