First Blog Post

A rundown of the quickly implemented blog system.

February 12, 2020

Hi. As you can tell, I've created a blog for the new website. Normally, I'd regard blogs as unnecessary, and effective wastes of data. Creating this blog did not sway that opinion at all—I still hold the same opinion. However, there's just something about writing thoughts to me that is very incentivizing. From now on, I will attempt to somewhat regularly post on this blog.

I spoke of the idea to my friend, Max, and he suggested that I

dont
i personally would use a static site gen tool

From there, I placed a bet that I would be able to create a basic blog renderer in less time than it would take me to set one up to work with my existing backend. Now as for whether or not I met this goal, I finished the renderer in about an hour and a half.

System

The file layout I use to store blog posts.

The blog system, like the rest of the backend, is written in Crystal. My initial thought process was that I could set some very simple code up to read files from a directory that contain metadata and post content.

When the webserver starts, a module called Blog is requested to load the posts. It does so by scanning the /blog directory for files ending in .yml. A Post object is then created for each matching file, and its information is filled in.

Each post has a very small amount of metadata, which is stored using YAML.

Referenced by the metadata post under the key content is a Markdown file in the same directory, featuring the contents of the blog post. The contents are parsed (or rendered, rather) at runtime, in which the webserver is able to serve the contents under certain conditions.

Blog index

The blog index (that is, /blog) shows the most recent five posts. It does so by reversing the list of blog posts stored internally and extracting blog posts that fit within a range of five. When more than five blog posts exist, a bar on the footer appears allowing for fine navigation of posts per units of five.

Ranges are handled as the query parameters from and to. By default, the blog index will show posts in the range (0...5).

Posts

Posts can be linked to immediately by clicking their title from the blog index. Clicking their title forwards the page to /blog/post/N, where N is the ID of the post. Post IDs are zero-indexed, so this post ID is 0. If you click this link, you will be taken to the direct link to this post.

Motivation to write

Throughout all hindrances considered through this process, among the greatest is my lack of the motivation to write. Writing about a certain topic spontaneously can be difficult. As I type this, I find myself pausing repeatedly, thinking of what I can impulsively add to the post. Although I lack the experience, it is likely that my posts should come from a culmination of thoughts throughout my day.

I asked a few friends before creating the blog about whether or not they'd read it. The general consensus was that they would read it as long as it didn't have all the code jargon, a rule in which I've already violated in this post.

Truthfully, this post doesn't need any fluff. It is a simple blog system that can be explained in under a page.

Your input

If I am to consistently produce posts for this blog, it would help to have some audience feedback. Perhaps things you'd like to read about, thoughts from my head, or suggestions to the blog system. You can best speak to me through the email [email protected].

I hope this post was at least somewhat interesting!