Add logic to handle non blog post md files
This commit is contained in:
parent
b016eab27b
commit
d490ca1e84
|
@ -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;
|
||||
|
||||
if (addToData) {
|
||||
this.data.posts.push(result);
|
||||
}
|
||||
console.log("[Compiler] File %s compiled", filepath);
|
||||
callback();
|
||||
});
|
||||
|
|
|
@ -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"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue