How I built this blog

Posted at 2022-10-11T04:56:00.000+10:00

I've always wanted to build a blog, a real blog. To me, that means it is fast, static, responsive, in markdown with as few images as possible, and has a full-text RSS feed.

Design

This section is where I pretend that I had a complete design in mind before I actually started building it. But in my defence, having some clear goals is more than enough for a personal project like this.

Firstly, the full text is very important to me, both in the RSS feed and on the actual home page. No 'read more' links, no unfold button, and no going to the link to read the full article in the RSS feed. Every post should be displayed on the home page in reverse chronological order. Yet every post should have its own individual page with a human-readable link.

I wanted to use thin, sans-serif fonts with muted theme colors for a modern look. After comparing the design of a few of my favorite personal blogs (none of which are exactly modern):

I chose Avenir Next used by marco.org for the font. As for the colors, the Morandi color palette is great for reading.

Development

Before this, I've heard (seen on YouTube and Reddit) a lot of good things about Next.js. React is the framework I'm most familiar with, but the heaviness and inelegance has always bothered me. So many third party packages and so much client side rendering. A site built with React has always felt bloated, or as kids these days call it—a hecking chonker. The dependency hell is hard to avoid, especially when I'm just starting, but the inelegance and heaviness was improved a lot by using Next.js. Despite being built on top of React—then on top of Node and then on top of JavaScript—Next supports server side rendering and most importantly, static site generation, which is perfect for a blog. Not to mention the free deployment provided by the creator of Next, Vercel. It is truly fantastic, just don't think about how much of the modern digital infrastructure is built in this way.

Jumping right in, search for a blog template on Vercel, clone, build, deploy, and hit the first brick wall. The template uses a very new library called Nextra, and its claim of having a blog in 10 minutes is real and spectacular. However, if you want some personality on your documentation or blog, there is no option to customize the completely white templates. Starting over with pure Next proved to be much better.

The rest of the process was very similar to developing with React, but on steroids. No need to worry about routing and pages, as long as you put the .js, .html, even in some cases .md files into the pages directory, it will automatically become a path on the server. The .md part, however, has proven to be the second brick wall. There is already a framework called MDX that allows using markdown files ending in—you guessed it— .mdx as both a markdown files and a .jsx component. However, taking this dream like component out of its context and into other JavaScript files as a component has proven to be a nightmare. Turns out, they were designed to be used as individual pages. Unintuitiveness while writing JavaScript? I know, truly unheard of. Abandoning that idea, the traditional marked library worked with few issues.

The last technical hurdle was actually building the RSS feed, which after trying 3 different methods, just would not work. Turns out the methods were all fine, I was just passing markdown into it instead of HTML, therefore completely breaking the feed. This is one of those situation where you completely understand you've died fair and square in Call of Duty but still have to call it bullshit in front of no one.

Future improvements

  • Dark mode

  • More markdown syntax support Which seems pretty difficult without creating my own markdown parsing library, so it will stay a long-term goal. Standard markdown is good enough for almost everything anyway.

  • Home page render limit. Will build this once there are too many blog posts.

  • Linking to external websites right in the title, like how Daring Fireball does it.

  • Automating posting so I don't have to manually build and deploy everytime.

Markdown style test

Posted at 2022-10-10T23:07:00.000+10:00

h1 Heading 8-)

h2 Heading

h3 Heading

h4 Heading

h5 Heading
h6 Heading

Horizontal Rules




Typographic replacements

Enable typographer option to see result.

(c) (C) (r) (R) (tm) (TM) (p) (P) +-

test.. test... test..... test?..... test!....

!!!!!! ???? ,, -- ---

"Smartypants, double quotes" and 'single quotes'

Emphasis

This is bold text

This is bold text

This is italic text

This is italic text

Strikethrough

Blockquotes

Blockquotes can also be nested...

...by using additional greater-than signs right next to each other...

...or with spaces between arrows.

Lists

Unordered

  • Create a list by starting a line with +, -, or *
  • Sub-lists are made by indenting 2 spaces:
    • Marker character change forces new list start:

      • Ac tristique libero volutpat at
      • Facilisis in pretium nisl aliquet
      • Nulla volutpat aliquam velit
  • Very easy!

Ordered

  1. Lorem ipsum dolor sit amet

  2. Consectetur adipiscing elit

  3. Integer molestie lorem at massa

  4. You can use sequential numbers...

  5. ...or keep all the numbers as 1.

Start numbering with offset:

  1. foo
  2. bar

Code

Inline code

Indented code

// Some comments
line 1 of code
line 2 of code
line 3 of code

Block code "fences"

Sample text here...

Syntax highlighting

var foo = function (bar) {
  return bar++;
};

console.log(foo(5));

Tables

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

Right aligned columns

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

link text

link with title

Autoconverted link https://github.com/nodeca/pica (enable linkify to see)

Images

Minion Stormtroopocat

Like links, Images also have a footnote style syntax

Alt text

With a reference later in the document defining the URL location:

Plugins

The killer feature of markdown-it is very effective support of syntax plugins.

Emojies

Classic markup: :wink: :crush: :cry: :tear: :laughing: :yum:

Shortcuts (emoticons): :-) :-( 8-) ;)

see how to change output with twemoji.

Subscript / Superscript

  • 19^th^
  • H2O

<ins>

++Inserted text++

<mark>

==Marked text==

Footnotes

Footnote 1 link[^first].

Footnote 2 link[^second].

Inline footnote^[Text of inline footnote] definition.

Duplicated footnote reference[^second].

[^first]: Footnote can have markup

and multiple paragraphs.

[^second]: Footnote text.

Definition lists

Term 1

: Definition 1 with lazy continuation.

Term 2 with inline markup

: Definition 2

    { some code, part of Definition 2 }

Third paragraph of definition 2.

Compact style:

Term 1 ~ Definition 1

Term 2 ~ Definition 2a ~ Definition 2b

Abbreviations

This is HTML abbreviation example.

It converts "HTML", but keep intact partial entries like "xxxHTMLyyy" and so on.

*[HTML]: Hyper Text Markup Language

Custom containers

::: warning here be dragons :::

External link test

Posted at 1970-01-01T00:00:00.000Z

tests linking to daring fireball