diff options
Diffstat (limited to 'lib/generate/site/index.js')
-rw-r--r-- | lib/generate/site/index.js | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js index f0ed784..87be7b4 100644 --- a/lib/generate/site/index.js +++ b/lib/generate/site/index.js @@ -59,8 +59,11 @@ Generator.prototype.loadPlugins = function() { }; // Generate a template -Generator.prototype._writeTemplate = function(tpl, options, output) { +Generator.prototype._writeTemplate = function(tpl, options, output, interpolate) { var that = this; + + interpolate = interpolate || _.identity; + return Q() .then(function(sections) { return tpl(_.extend({ @@ -80,6 +83,7 @@ Generator.prototype._writeTemplate = function(tpl, options, output) { pluginsConfig: JSON.stringify(that.options.pluginsConfig) }, options)); }) + .then(interpolate) .then(function(html) { return fs.writeFile( output, @@ -107,6 +111,15 @@ Generator.prototype.convertFile = function(content, _input) { return Q() .then(function() { + // Send content to plugins + return that.callHook("page:before", { + path: _input, + content: content + }); + }) + .then(function(_content) { + content = _content.content; + // Lex page return parse.lex(content); }) @@ -126,8 +139,8 @@ Generator.prototype.convertFile = function(content, _input) { .then(function(sections) { // Use plugin hook return that.callHook("page", { - sections: sections, - progress: progress + path: _input, + sections: sections }) }) .then(function(_page) { @@ -141,7 +154,12 @@ Generator.prototype.convertFile = function(content, _input) { basePath: basePath, staticBase: path.join(basePath, "gitbook"), - }, output); + }, output, function(html) { + return that.callHook("page:after", { + path: _input, + content: html + }).get("content") + }); }); }; |