The time has come - I'm officially launching my blog 🎉
In this opening article, I'll share how the blog was built. In short, I wrote a small utility called milky
. It's just a basic HTML generator from markdown format. If you're curious, the source code is open and available in the linked repository
What will the blog be about?
Mainly programming, primarily in Rust 🦀
I have a few topics in mind, but I'd be happy if anyone suggests something they'd like to read about
What language will the blog be in?
I spent a while thinking about what language to use. On the one hand, writing in English makes sense to reach a wider audience. On the other, I really want to help grow the local Russian-speaking community. Moreover, a lot of content would need to be translated anyway - so why not make both languages available from the start? In the future, maybe more languages could be added if someone helps with translations. The generator is designed from the start to support any number of translations for a single article 🥰
Thanks, that's the end of the announcement! To avoid publishing an empty blog, I've also written a full article about trait bounds. I'll follow up for anyone interested in the technical details of the implementation
How it works
Let's talk briefly about the implementation. Naturally, the whole generator is written in Rust. It produces simple static HTML pages, with no extra bells and whistles. The visual design was made and styled from scratch (sometimes sloppily 😗).
The generator is intentionally minimalist and includes only essential dependencies:
maud
- HTML templatingpulldown-cmark
- markdown parserserde
- serializationsyn
- basic Rust code parsingtime
- to set article publication datestoml
- used for configuration and metadata
It's interesting that Rust is often labeled a "systems" language, for writing complex performance-critical software. But is it a good fit for something high-level and simple, like a blog page generator? Well, the source code is open - you can decide for yourself how true that assumption is
Sure, the project uses a lot of lifetimes. Just look at this data structure used to generate a page:
pub struct Make<'art> {
pub l: Localizer<'art>,
pub blog: &'art str,
pub title: &'art str,
pub translations: &'art mut dyn Iterator<Item = Translation>,
pub social: &'art [Social],
pub target: Target<'art>,
}
pub enum Target<'art> {
List(&'art [Post<'art>]),
Article {
md: &'art str,
date: Date,
index_href: String,
deps: &'art mut HashSet<Box<str>>,
},
}
pub fn make(make: Make<'_>) -> maud::Markup {/**/}
But really, it's just one shared lifetime 'art
- it only refers to borrowed data passed to the make
function. Other lifetimes are straightforward as well, and mostly represent temporary borrows during page generation. The rest of the code is quite simple and straightforward
Configuration
The configuration is defined in a Milky.toml
file in a format like this:
[blog]
title = "Nano Memories"
[article.hello_blog]
ru = { title = "Открытие Блога!" }
en = { title = "Blog Opening!" }
[[social]]
href = "https://github.com/nanoqsh"
icon = "gh"
The toml files also define language localizations and store metadata
Future plans
Overall, I can say development was really fun. It's that kind of project where you start off writing a bit of code, then realize you need one more thing, then another, and another. Also, this is my first time writing anything even close to full-length articles ❤️
I already have a lot of improvements in mind, which I'll get to later. What kind of blog doesn't have tags, right? For now, I invite you to follow me on the socials I conveniently placed in the footer 🐾