Skip to content

Instantly share code, notes, and snippets.

@firelizzard18
Created November 19, 2017 04:51
Show Gist options
  • Save firelizzard18/934c274df0e6699e3fcad46cc62df501 to your computer and use it in GitHub Desktop.
Save firelizzard18/934c274df0e6699e3fcad46cc62df501 to your computer and use it in GitHub Desktop.
patch-package
--- a/index.js
+++ b/index.js
@@ -31,12 +31,16 @@ function processFile(filePath) {
.then(middleware)
.then(getDefaults)
.then(data => {
+ if (data._draft && !conf.draft) return;
+
// If _layout, render it:
if (data._layout) return render(data);
// Else, return _body:
else return data._body;
})
.then(html => {
+ if (html === void 0) return;
+
// Get path to write to using path-extra:
var writePath = path.replaceExt(path.join(conf.dist, filePath), '.html');
// Output using fs-extra:
@@ -72,7 +76,7 @@ function middleware(data) {
case '.md':
case '.markdown':
// Render markdown:
- return marked(data._body)
+ return (conf.renderer || marked)(data._body)
.then(res => {
// Overwrite data._body:
data._body = res;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment