diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | lib/generators/site.js | 22 | ||||
-rw-r--r-- | test/generation.js | 1 |
3 files changed, 19 insertions, 5 deletions
@@ -10,3 +10,4 @@ ChangeLog with 1.0.0: - Exercises and Quizzes are no longer parsed in the markdown parser - You can now also use the `.markdown` extension for markdown files - Templates are rendered with nunjucks instead of swig, syntax is almost compatible, there is some changes with contexts and filters. +- `{{ super() }}` should be use instead of `{% parent %}` diff --git a/lib/generators/site.js b/lib/generators/site.js index a19da25..cd63bbe 100644 --- a/lib/generators/site.js +++ b/lib/generators/site.js @@ -59,7 +59,7 @@ Generator.prototype.prepareStyles = function() { Generator.prototype.prepareTemplates = function() { this.pageTemplate = this.plugins.template("site:page") || path.resolve(this.templatesRoot, 'page.html'); this.langsTemplate = this.plugins.template("site:langs") || path.resolve(this.templatesRoot, 'langs.html'); - this.glossaryTemplate = this.plugins.template("site:glossary") || path.resolve(this.templatesRoot, 'templates/website/glossary.html'); + this.glossaryTemplate = this.plugins.template("site:glossary") || path.resolve(this.templatesRoot, 'glossary.html'); var folders = _.chain( [ @@ -69,8 +69,6 @@ Generator.prototype.prepareTemplates = function() { .uniq() .value(); - console.log("templates folders", folders) - this.env = new nunjucks.Environment( new nunjucks.FileSystemLoader(folders), { @@ -78,6 +76,9 @@ Generator.prototype.prepareTemplates = function() { } ); + // Add filter + this.env.addFilter("contentLink", this.contentLink.bind(this)); + // Add extension this.env.addExtension('ParentExtension', new ParentExtension()); this.env.addExtension('AutoEscapeExtension', new AutoEscapeExtension(this.env)); @@ -96,11 +97,24 @@ Generator.prototype.finish = function() { }; +// Normalize a link to .html and convert README -> index +Generator.prototype.contentLink = function(link) { + if ( + path.basename(link) == "README" + || link == this.book.readmeFile + ) { + link = path.join(path.dirname(link), "index"+path.extname(link)); + } + + link = links.changeExtension(link, ".html"); + return link; +} + // Convert an input file Generator.prototype.writeParsedFile = function(page) { var that = this; - var output = links.changeExtension(page.path, ".html"); + var output = this.contentLink(page.path); output = path.join(that.options.output, output); return that.normalizePage(page) diff --git a/test/generation.js b/test/generation.js index c2c8094..d2d0574 100644 --- a/test/generation.js +++ b/test/generation.js @@ -51,7 +51,6 @@ describe('Book generation', function () { it('should correctly generate a book to website', function(done) { testGeneration(book1, "site", function(output) { - console.log(fs.readdirSync(output)); assert(fs.existsSync(path.join(output, "index.html"))); }, done); }); |