From 84f706bf307673a26e81ea376dc7852317082bc9 Mon Sep 17 00:00:00 2001 From: LordMathis Date: Sun, 12 Aug 2018 12:41:28 +0200 Subject: [PATCH 1/2] Implement draft support --- src/utils/compiler.js | 15 ++++++++++++--- webpack.config.js | 4 +++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/utils/compiler.js b/src/utils/compiler.js index 0735bb1..ca4b6c5 100644 --- a/src/utils/compiler.js +++ b/src/utils/compiler.js @@ -40,6 +40,11 @@ function compilePost(filepath, data, fileData, callback) { const rendered = render(frontMatter.body); const metadata = fileMetadata(filepath); + if (frontMatter.attributes.draft) { + callback(null, null); + return; + } + let published; if (frontMatter.attributes.date) { published = moment(frontMatter.attributes.date); @@ -99,9 +104,13 @@ Compiler.prototype.addFile = function(filepath, isPost, callback) { ], (err, result) => { if (err) throw err; - this.data.posts.push(result); - console.log("[Compiler] File %s compiled", filepath); - callback(); + if (result == null) { + callback(); + } else { + this.data.posts.push(result); + console.log("[Compiler] File %s compiled", filepath); + callback(); + } }); } else { async.waterfall([ diff --git a/webpack.config.js b/webpack.config.js index f3a1c27..a1ee9dc 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,7 @@ const { resolve, join } = require('path') const webpack = require('webpack') const ManifestPlugin = require('webpack-manifest-plugin'); +const CleanWebpackPlugin = require('clean-webpack-plugin') const config = { mode: 'development', @@ -68,7 +69,8 @@ const config = { new webpack.HotModuleReplacementPlugin(), new webpack.NoEmitOnErrorsPlugin(), new webpack.NamedModulesPlugin(), - new ManifestPlugin({'writeToFileEmit': true}) + new ManifestPlugin({'writeToFileEmit': true}), + new CleanWebpackPlugin(['public/static'], {}), ] } module.exports = config From 68be0338fcf75b877ed30f7241a5460fe9d0bd11 Mon Sep 17 00:00:00 2001 From: LordMathis Date: Sun, 12 Aug 2018 15:52:27 +0200 Subject: [PATCH 2/2] Remove webpack plugins --- webpack.config.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index a1ee9dc..da607ab 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,7 +1,6 @@ const { resolve, join } = require('path') const webpack = require('webpack') const ManifestPlugin = require('webpack-manifest-plugin'); -const CleanWebpackPlugin = require('clean-webpack-plugin') const config = { mode: 'development', @@ -70,7 +69,6 @@ const config = { new webpack.NoEmitOnErrorsPlugin(), new webpack.NamedModulesPlugin(), new ManifestPlugin({'writeToFileEmit': true}), - new CleanWebpackPlugin(['public/static'], {}), ] } module.exports = config