From d490ca1e84b55fa99cbd2d1bfbd51d4ebce9dd1a Mon Sep 17 00:00:00 2001 From: LordMathis Date: Wed, 15 Nov 2017 18:21:52 +0100 Subject: [PATCH] Add logic to handle non blog post md files --- src/utils/compiler.js | 6 ++++-- src/utils/config.json | 5 ++++- src/utils/scanner.js | 7 ++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/utils/compiler.js b/src/utils/compiler.js index e4a9802..8ae9c53 100644 --- a/src/utils/compiler.js +++ b/src/utils/compiler.js @@ -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(); }); diff --git a/src/utils/config.json b/src/utils/config.json index 41a85ae..90e7afb 100644 --- a/src/utils/config.json +++ b/src/utils/config.json @@ -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" + ] } diff --git a/src/utils/scanner.js b/src/utils/scanner.js index 829ed51..60842a5 100644 --- a/src/utils/scanner.js +++ b/src/utils/scanner.js @@ -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) {