From: Ben Beltran Date: Mon, 3 Jul 2017 06:38:51 +0000 (-0500) Subject: Merge branch 'hotfix/1.0.1' into develop X-Git-Tag: 5.0.0~30 X-Git-Url: https://git.r.bdr.sh/rbdr/blog/commitdiff_plain/aaf169bdf57cc512413f19009319e51ef4b98525?hp=47a29df7b36312b2c7733a21d15d32bdbd5f445e Merge branch 'hotfix/1.0.1' into develop --- 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;