aboutsummaryrefslogtreecommitdiff
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
parent47a29df7b36312b2c7733a21d15d32bdbd5f445e (diff)
parent8ca5460b5445f46520046e31f79547d282e8fc30 (diff)
Merge branch 'hotfix/1.0.1' into develop
-rw-r--r--CHANGELOG.md13
-rw-r--r--lib/blog.js38
-rw-r--r--package.json6
-rw-r--r--static/css/style.css13
4 files changed, 53 insertions, 17 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a468b24..a643cc0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
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}`);
diff --git a/package.json b/package.json
index e5303b1..9351dfc 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "blog",
- "version": "1.0.0",
+ "version": "1.0.1",
"description": "An ephemeral blog",
"main": "lib/blog.js",
"bin": {
@@ -23,11 +23,11 @@
"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",
diff --git a/static/css/style.css b/static/css/style.css
index aeda780..c18e6fa 100644
--- a/static/css/style.css
+++ b/static/css/style.css
@@ -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;