aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBen Beltran <ben@nsovocal.com>2017-07-03 01:38:51 -0500
committerBen Beltran <ben@nsovocal.com>2017-07-03 01:38:51 -0500
commitaaf169bdf57cc512413f19009319e51ef4b98525 (patch)
tree6808c87d44fca13f3b77960778a7a1f007e99205 /lib
parent47a29df7b36312b2c7733a21d15d32bdbd5f445e (diff)
parent8ca5460b5445f46520046e31f79547d282e8fc30 (diff)
Merge branch 'hotfix/1.0.1' into develop
Diffstat (limited to 'lib')
-rw-r--r--lib/blog.js38
1 files changed, 26 insertions, 12 deletions
diff --git a/lib/blog.js b/lib/blog.js
index 483577f..f31234b 100644
--- a/lib/blog.js
+++ b/lib/blog.js
@@ -1,11 +1,11 @@
'use strict';
const Fs = require('fs');
-const Markdown = require('markdown');
const Mustache = require('mustache');
const Ncp = require('ncp');
const Path = require('path');
const Rimraf = require('rimraf');
+const Showdown = require('showdown');
const Util = require('util');
const internals = {
@@ -112,20 +112,34 @@ module.exports = class Blog {
for (let i = 0; i < this.maxPosts; ++i) {
const sourcePath = Path.join(this.postsDirectory, `${i}`);
- const assetsSource = Path.join(sourcePath, internals.kAssetsDirectoryName);
- const postContentPath = await this._findBlogContent(sourcePath);
- internals.debuglog(`Copying ${assetsSource} to ${assetsTarget}`);
- await internals.ncp(assetsSource, assetsTarget);
+ try {
+ await internals.fs.access(this.postsDirectory);
+
+ const assetsSource = Path.join(sourcePath, internals.kAssetsDirectoryName);
+ const postContentPath = await this._findBlogContent(sourcePath);
+
+ internals.debuglog(`Copying ${assetsSource} to ${assetsTarget}`);
+ await internals.ncp(assetsSource, assetsTarget);
- internals.debuglog(`Reading ${postContentPath}`);
- const postContent = await internals.fs.readFile(postContentPath, { encoding: 'utf8' });
+ internals.debuglog(`Reading ${postContentPath}`);
+ const postContent = await internals.fs.readFile(postContentPath, { encoding: 'utf8' });
- internals.debuglog('Parsing markdown');
- posts.push({
- html: Markdown.markdown.toHTML(postContent),
- id: i + 1
- });
+ internals.debuglog('Parsing markdown');
+ const parser = new Showdown.Converter();
+ posts.push({
+ html: parser.makeHtml(postContent),
+ id: i + 1
+ });
+ }
+ catch (error) {
+ if (error.code === internals.kFileNotFoundError) {
+ internals.debuglog(`Skipping ${i}`);
+ continue;
+ }
+
+ throw error;
+ }
}
internals.debuglog(`Reading ${indexLocation}`);