Commit c4b2d5e0 authored by Isabella Skořepová's avatar Isabella Skořepová

Also write other rendered types

parent 1449e2ae
......@@ -101,7 +101,7 @@ module.exports = function(data, type) {
//reject(new Error('Error rendering template '+o.file));
reject(err);
}
resolve({val: val, type: o.type});
resolve({content: val, type: o.type});
});
}));
});
......
......@@ -12,7 +12,7 @@ module.exports = function(obj) {
jobs.run('nunjucks', obj, type)
.then(function(data) {
data.forEach(function(o){
if(o.type == 'html') obj.content = o.val;
if(o.type == 'html') obj.content = o.content;
else {
if(!obj.otherContent) obj.otherContent = [];
obj.otherContent.push(o);
......
......@@ -8,16 +8,28 @@ module.exports = function(obj) {
var builddir = obj.config.builddir;
var todo = 0;
var writeFile = function(article) {
var filename = path.join(builddir,article.file,'index.html');
mkdirp(path.dirname(filename), function() {
fs.writeFile(filename, article.content, function(err) {
var doWrite = function(file, content) {
todo++;
mkdirp(path.dirname(file), function() {
fs.writeFile(file, content, function(err) {
if(err) reject(err);
todo--;
if(todo <= 0) resolve(obj);
});
});
}
var writeFile = function(article) {
var filename = path.join(builddir,article.file,'index.html');
doWrite(filename, article.content);
if(article.otherContent) {
article.otherContent.forEach(function(o) {
var f = path.join(builddir,article.file,'index.'+o.type);
console.log(f);
doWrite(f, o.content);
})
}
}
obj.pages.forEach(function(o) { writeFile(o); })
obj.redirects.forEach(function(o) { writeFile(o); })
obj.tags.forEach(function(o) { writeFile(o); })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment