diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-20 13:30:22 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-20 13:30:22 +0100 |
commit | a5ebbc34c7333880b5a194cbe26041029e2cdbfb (patch) | |
tree | a627166ebafc9af50af7cf948bf67a977144b775 /lib/generators | |
parent | 33e32b20d997d688ebb231b92b4e7e1423c2aeec (diff) | |
download | gitbook-a5ebbc34c7333880b5a194cbe26041029e2cdbfb.zip gitbook-a5ebbc34c7333880b5a194cbe26041029e2cdbfb.tar.gz gitbook-a5ebbc34c7333880b5a194cbe26041029e2cdbfb.tar.bz2 |
Add styles configuration in book.json
Diffstat (limited to 'lib/generators')
-rw-r--r-- | lib/generators/site.js | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/lib/generators/site.js b/lib/generators/site.js index 7a2a3aa..6caf372 100644 --- a/lib/generators/site.js +++ b/lib/generators/site.js @@ -12,14 +12,50 @@ var pageUtil = require("../utils/page"); var Generator = function() { BaseGenerator.apply(this, arguments); - this.env = new nunjucks.Environment( - new nunjucks.FileSystemLoader(book.root), + // Style to integrates i nthe output + this.styles = ["website"]; + + // base folder for templates + this.templatesRoot = path.resolve(__dirname, "../../theme/templates/website") +}; +util.inherits(Generator, BaseGenerator); + +// Prepare the genertor +BaseGenerator.prototype.load = function() { + var that = this; + + return BaseGenerator.prototype.load.apply(this) + .then(function() { + return that.loadTemplates(); + }); +}; + +// Load all styles +Generator.prototype.loadStyles = function() { + var that = this; + this.styles = _.chain(this.styles) + .map(function(style) { + var stylePath = that.options.styles[style]; + if (fs.existsSync(path.resolve(that.book.root, stylePath))) { + return stylePath; + } + return null; + }) + .compact() + .value(); +}; + +// Load template engine +Generator.prototype.loadTemplates = function() { + this.env = new nunjucks.Environment( + new nunjucks.FileSystemLoader(this.templatesRoot), { autoescape: true } ); + + return Q(); }; -util.inherits(Generator, BaseGenerator); // Ignore some methods Generator.prototype.transferFile = function(input) { |