]> git.r.bdr.sh - rbdr/blog/commitdiff
Merge branch 'hotfix/1.0.1' into develop
authorBen Beltran <redacted>
Mon, 3 Jul 2017 06:38:51 +0000 (01:38 -0500)
committerBen Beltran <redacted>
Mon, 3 Jul 2017 06:38:51 +0000 (01:38 -0500)
CHANGELOG.md
lib/blog.js
package.json
static/css/style.css

index a468b24b31746c312df0ccef8a87c30700af3b81..a643cc0898cd9d9ebb3e2ef7698e921799c4dcaa 100644 (file)
@@ -4,7 +4,17 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](http://keepachangelog.com/)
 and this project adheres to [Semantic Versioning](http://semver.org/).
 
-## v1.0.0 - 2017-07-03
+## [1.0.1] - 2017-07-03
+### Added
+- Add styling for code
+
+### Changed
+- Swap markdown engine for showdown
+- Remove `v` from CHANGELOG
+- Fix crash when generator attempted to run without 3 posts
+
+
+## 1.0.0 - 2017-07-03
 ### Added
 - JSDoc config
 - Eslint config
@@ -16,3 +26,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
 - A Readme
 
 [Unreleased]: https://github.com/rbdr/blog/compare/master...develop
+[1.0.1]: https://github.com/rbdr/blog/compare/1.0.0...1.0.1
index 483577ff3f147b30b02d818970d6ceb38e7ef514..f31234b526f7289f767bbadb04bb47134c0d9798 100644 (file)
@@ -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}`);
index e5303b110584c64420412231d173718bbed6ce26..9351dfc7810addc770a8b822e5829ff00096b2e0 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "blog",
-  "version": "1.0.0",
+  "version": "1.0.1",
   "description": "An ephemeral blog",
   "main": "lib/blog.js",
   "bin": {
   "homepage": "https://github.com/rbdr/blog#readme",
   "dependencies": {
     "getenv": "0.7.x",
-    "markdown": "0.5.x",
     "minimist": "1.2.x",
     "mustache": "2.3.x",
     "ncp": "2.0.x",
-    "rimraf": "2.6.x"
+    "rimraf": "2.6.x",
+    "showdown": "1.7.x"
   },
   "devDependencies": {
     "docdash": "0.4.x",
index aeda780d31160919fdd91065cb5ad13df22327ac..c18e6fa9528fcad9bbe5aecd08ef8050bfbf82b0 100644 (file)
@@ -24,7 +24,7 @@ header a {
 }
 
 main {
-  background-color: #fff;
+  background-color: white;
   padding: 1.414em;
 }
 
@@ -46,6 +46,17 @@ h2 { font-size: 2.827em; }
 h3 { font-size: 1.999em; }
 h4 { font-size: 1.414em; }
 
+code {
+  background-color: whitesmoke;
+  padding: 0.2em 0.5em;
+}
+
+pre {
+  background-color: whitesmoke;
+  padding: 1em;
+  max-width: 40em;
+}
+
 footer {
   background-color: pink;
   padding: 1.414em;