ThomasFerro / thomasferro.github.com

Blog posts and stuff
MIT License
0 stars 0 forks source link

Post idea : Statically generated blogging platform using Go HTML templating #23

Open ThomasFerro opened 5 years ago

ThomasFerro commented 5 years ago
ThomasFerro commented 5 years ago

Statically generated blogging platform using Go HTML templating

And why your static website should not send me megabytes of JS frameworks.

Before I found out about Go HTML templating

I am really found of Vue.js. Building the front-end of my applications with this framework feels fluid and just good.

I used it regularly for the past three years, always learning advanced concepts and patterns and even becoming a Vue.js trainer.

I also do like Javascript. It may have his flaws but it is a quit good language to start developing either front or back-end.

What I do not like however is to send megabytes and megabytes of Javascript code to the client when he simply wants to browse a static website.

I want users of my web applications to have a good time. I want them to have the best possible experience, starting with the loading time. I want my application to be accessible to everyone, even to the users with slow Internet connection or those who disable Javascript.

I found nothing more frustrating with modern Web than browsing a news site to get a single information. Having to wait for the page to load, the cookies preferences popup to be thrown at me and finally getting hit by a paywall.

Great talk, right? But what about actions? What did I do to meet those expectations? Especially in the making of my blogging application.

First, we can easily assume that the articles are not going to change every ten seconds. No need for the application to call some API that returns the articles up-to-date. The site can be statically generated when a new article is written.

Another important matter is the Javascript. In the MVP, none seems to be needed. When the time to add dynamic elements will come, only the bare minimum of JS will be written.

TODO: Relire à partir d'ici

When the question came to choose the technologies behind the front-end of my blogging application, I had many choices including :

I have chosen the latest.

In the meantime, I was really intrigued by the Go programming language and decided to build the back-end with it.

Why not doing Server-side rendering with Go too ? And why not save the output to be able to statically serve the HTML files ?

Life of an article

An article go through different stages during his life. It first has to be written before it can be published. Once published, the author can decide to revise it for many reasons. May it be for fixing typos or for an update of the subject.

To match this simple domain matters, we will create a Article aggregate, which API exposes two commands: Publish and Revise.

ThomasFerro commented 5 years ago

I will not be using the html/template package in the Markdown to HTML module because the spec specifies the following :

Using Markdown doesn't mean that you can't also use HTML. You can add HTML tags to any Markdown file. This is helpful if you prefer certain HTML tags to Markdown syntax. For example, some people find that it's easier to use HTML tags for images.

This module will be used as a Generic Subdomain by the Core Domain.

The html/template package will be used when building the actual HTML pages. Example :

<!doctype html>
<html lang="{{ .Locale }}">
<head>
  <meta charset="utf-8">
  <title>{{ .Title }}</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
{{ .Content }}
</body>
</html>
ThomasFerro commented 4 years ago

==> To be moved in another article about the making of a Markdown to HTML converter.

First implementation idea: using regular expressions


Keep it simple, stupid. There is no rich domain right now and there is always room to make it shine if I discover it later on.

The first implementation will only do the following: