generate an index.html for entry points

This commit is contained in:
Samy Pessé
2015-01-21 19:40:40 +01:00
parent bd931c5cbd
commit 3c605ea809
3 changed files with 19 additions and 5 deletions
+1
View File
@@ -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 %}`
+18 -4
View File
@@ -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)
-1
View File
@@ -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);
});