summaryrefslogtreecommitdiffstats
path: root/lib/generators/website.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-01-27 11:15:16 +0100
committerSamy Pessé <samypesse@gmail.com>2015-01-27 11:15:16 +0100
commit6125df58340456529cfb180cc62308cc00e4e769 (patch)
tree38cfe330153bc2bb8fcaef18cb446373ee0de0f9 /lib/generators/website.js
parent99cd3148ba99a7bf5afaa9b1bb51749411de9d18 (diff)
downloadgitbook-6125df58340456529cfb180cc62308cc00e4e769.zip
gitbook-6125df58340456529cfb180cc62308cc00e4e769.tar.gz
gitbook-6125df58340456529cfb180cc62308cc00e4e769.tar.bz2
Add back "page:before" hook
Diffstat (limited to 'lib/generators/website.js')
-rw-r--r--lib/generators/website.js24
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/generators/website.js b/lib/generators/website.js
index ba1d2ce..08950c8 100644
--- a/lib/generators/website.js
+++ b/lib/generators/website.js
@@ -123,19 +123,25 @@ Generator.prototype.finish = function() {
};
// Convert an input file
-Generator.prototype.writeParsedFile = function(page) {
+Generator.prototype.convertFile = function(input) {
var that = this;
- var relativeOutput = this.book.contentLink(page.path);
- var output = path.join(that.options.output, relativeOutput);
+ return that.book.parsePage(input, {
+ interpolateTemplate: function(page) {
+ return that.callHook("page:before", page);
+ },
+ interpolateContent: function(page) {
+ return that.callHook("page", page);
+ }
+ })
+ .then(function(page) {
+ var relativeOutput = that.book.contentLink(page.path);
+ var output = path.join(that.options.output, relativeOutput);
- var basePath = path.relative(path.dirname(output), this.options.output) || ".";
- if (process.platform === 'win32') basePath = basePath.replace(/\\/g, '/');
+ var basePath = path.relative(path.dirname(output), that.options.output) || ".";
+ if (process.platform === 'win32') basePath = basePath.replace(/\\/g, '/');
- that.book.log.info.ln("write parsed file", page.path, "to", relativeOutput);
- return that.normalizePage(page)
- .then(function(_page) {
- page = _page;
+ that.book.log.info.ln("write parsed file", page.path, "to", relativeOutput);
return that._writeTemplate(that.templates["page"], {
progress: page.progress,