blogdown is a lightweight blog engine written in Node.js that serves static markdown articles.
See install instructions for Node.js at nodejs.org. You will also need Express and EJS (use node package manager)
$ npm install express
$ npm install ejs
Start the server by running the following command.
$ node server.js
By default, server.js will parse markdown articles (.md extension) located in /articles. All articles need to start with a line of the following format (each attribute separated by a double pipe):
Article Title||Author||Date||Published
// Example:
Test Article #1||Mikael Bjorkstam||04/24/2011||true
// The following article will be ignored
Some Article in Progress||Mikael Bjorkstam||04/24/2011||false
- Article title
- A slug will be generated based on this title
- Author
- Date
- will be parsed into a JavaScript Date object
- Published
- boolean => true or false
Only articles with the published flag set to true will be loaded. Once an article has been loaded, showdown.js is used to parse the markdown into html.
blogdown comes with prettify by default, which syntax highlights code blocks.
Static files are served under /public
The benefit of blogdown is that once the server has started, all the files are parsed and stored in memory. There is no database needed, nor will the server access the filesystem on every request.
Should you wish to reload the articles from the filesystem, you can do so by accessing /api/refresh/?key=API_KEY. The following example will re-parse all articles:
curl http://localhost:8080/api/refresh/?key=demo
Note that in order for any changes to an article to take effect, the articles must be re-parsed.
Right now, the error handling isn't working 100% properly (the 404 page is not rendered as intended)