Add logic to handle non blog post md files

This commit is contained in:
LordMathis 2017-11-15 18:21:52 +01:00
parent b016eab27b
commit d490ca1e84
3 changed files with 14 additions and 4 deletions

View File

@ -59,14 +59,16 @@ function Compiler(data) {
this.data = data;
}
Compiler.prototype.addFile = function(filepath, callback) {
Compiler.prototype.addFile = function(filepath, addToData, callback) {
async.waterfall([
fs.readFile.bind(fs, filepath, 'utf8'),
compile.bind(compile, filepath, this.data),
], (err, result) => {
if (err) throw err;
this.data.posts.push(result);
if (addToData) {
this.data.posts.push(result);
}
console.log("[Compiler] File %s compiled", filepath);
callback();
});

View File

@ -13,5 +13,8 @@
"linkedin": "https://www.linkedin.com/in/mat%C3%BA%C5%A1-n%C3%A1me%C5%A1n%C3%BD-3903b6128/"
},
"contentPath": "./content",
"renderPath": "./renders"
"renderPath": "./renders",
"files": [
"about.md", "resume.md"
]
}

View File

@ -15,7 +15,12 @@ module.exports = function() {
function compileFile(file, callback) {
const filePath = path.join(process.cwd(), config.contentPath, file);
compiler.addFile(filePath, callback);
if (config.files.indexOf(file) !== -1) {
compiler.addFile(filePath, false, callback);
} else {
compiler.addFile(filePath, true, callback);
}
}
function compile(files, callback) {