The Plugin
After installing the plugin with npm:
npm install metalsmith-word-count --save
I required the plugin in build.js
var tags = require('metalsmith-word-count');
Incorporating this plugin was as simple as it gets. All I had to do was place
it once the html files were ready, after .use(markdown)
:
Metalsmith(__dirname)
// plugins
.use(markdown())
.use(wordcount())
// plugins continued
Displaying the information in the post.jade
template, after published
date:
.published #{moment(publishDate).format("Do MMM YYYY")}
if modifyDate && moment(publishDate).isBefore(modifyDate)
span - updated #{moment(modifyDate).format("Do MMM YYYY")}
.wordcount #{readingTime} read
The reading time information is formatted nicely by default and more options are available if necessary.
What Next?
Next I will look into including a new 'Post Type' a.k.a Collection for my projects/portfolio.
More info
How I built this site using Node.js
Using Metalsmith - Adding Tags
metalsmith-word-count