Skip to content
/ blog Public

My blog, nothing special just boring and ramblings

License

Notifications You must be signed in to change notification settings

njb-said/blog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blog Build Status Known Vulnerabilities

This repository contains the server that powers my blog, as well as all the posts. I can't promise I'll blog often or be remotely interesting, but if you find it somewhat interesting that's fine with me!

Builds are run on Travis CI for eslint compatibility and snyk is used for package security checks.

Posts

So all the posts are stored in the posts directory and are markdown files.
These are parsed at runtime with the marked library and have a browser cache time of 1 day by default. This can be overridden using the environment variable CACHE_HOURS.
The homepage shows a list of blog posts, sorted by their date.
Meta data about posts are in the posts/meta directory and are JSON files, these can have the following attributes:

  • title The title of the post
  • date The date of the post (in ISO format, you can find the date + time using new Date().toISOString() in a javascript console)
  • author The name of the person who wrote this post (optional)

You can generate a meta file using the /new_post page. This also has a markdown editor (SimpleMDE), you can also generate a slug for your post there too.

Backend

The actual server is written in node.js running a simple express app, which in my setup is fronted by Varnish for caching and then CloudFlare for global distribution.

The express server will load everything in the posts folder at startup and the associated meta files in posts/meta.

To change the blog title open web.js and change line 41 to the name of your blog, similarly change line 44 to your Google Analytics code to enable this (see below)

Analytics

For analytics I decided to just use Google Analytics, I didn't think it was worth introducing any other complexity or dependencies for now.