diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-17 17:34:27 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-17 17:34:27 +0100 |
commit | 9caa9c39e59aba47de1646081591ed4c826abfe6 (patch) | |
tree | 067ffa1351cb6624df8de5361dac8dbd48db1e48 | |
parent | 096bdaba7aa11d56e0356386faaecb189f3100d4 (diff) | |
download | gitbook-9caa9c39e59aba47de1646081591ed4c826abfe6.zip gitbook-9caa9c39e59aba47de1646081591ed4c826abfe6.tar.gz gitbook-9caa9c39e59aba47de1646081591ed4c826abfe6.tar.bz2 |
Use _layouts folders as base for templates
-rw-r--r-- | lib/output/website.js | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/output/website.js b/lib/output/website.js index 1ec0548..a208802 100644 --- a/lib/output/website.js +++ b/lib/output/website.js @@ -12,6 +12,11 @@ function themeID(plugin) { return 'theme-' + plugin; } +// Directory for a theme with the templates +function templatesPath(dir) { + return path.join(dir, '_layouts'); +} + function WebsiteOutput() { Output.apply(this, arguments); @@ -50,15 +55,16 @@ WebsiteOutput.prototype.prepare = function() { var searchPaths = _.chain([ // The book itself can contains a "_layouts" folder - that.book.root, + '_layouts', // Installed plugin (it can be identical to themeDefault.root) - that.theme.root, + '_layouts', // Is default theme still installed that.themeDefault? that.themeDefault.root : null ]) .compact() + .map(templatesPath) .uniq() .value(); @@ -87,8 +93,13 @@ WebsiteOutput.prototype.prepare = function() { WebsiteOutput.prototype.onPage = function(page) { var that = this; + // Parse the page + return page.toHTML(this) + // Render the page template with the same context as the json output - return this.render('page', this.getPageContext(page)) + .then(function() { + return that.render('page', that.getPageContext(page)); + }) // Write the HTML file .then(function(html) { @@ -109,7 +120,7 @@ WebsiteOutput.prototype.render = function(tpl, context) { // Return a complete name for a template WebsiteOutput.prototype.templateName = function(name) { - return path.join('_layouts', this.name, name+'.html'); + return path.join(this.name, name+'.html'); }; module.exports = conrefsLoader(WebsiteOutput); |