What I was using is a badly written bash script that depends on pup and pandoc. I don't mind the pandoc dependency too much as I have it on all my systems anyway. But the script is messy and I'd rather have something cleaner.
"Why not just use x?"
Most of the static site generators I've seen like Hugo and Jekyll seem too complicated for me. I'm not saying I can't use them, I just felt some friction and thought it would be cool to build my own.
My requirements for the current script were:
- Must have as few dependencies as possible.
- Must work on UNIX/UNIX-like systems
- Must generate an RSS file with all blog posts
- Must arrange blog posts by date
I didn't put too much thought into how the old script worked. I started by writing a function that compiles the markdown files of my blog posts. Everything else came after that. Whenever I hit a roadblock, I looked for a program that could help me. In the end, I had a hacky script that worked but I wasn't proud of it. I also started to run into problems when I wanted to add new functionality or change something.
The current script is not as bad.
The way that it works is, it assumes every directory(including the root directory) has an src
subdirectory.
It compiles every markdown file in the src
subdirectories to HTML files that live in the directory itself.
To get away with not creating an index.html
I create an index.md
instead and that gets compiled like every other markdown file.
That's the core of how it works.
If you want the details, read the script.
I'm happy with how it works right now but there's a minor annoyance I have with it. The blog posts are arranged according to their dates by putting the date in the file name.
Yuck.1
I tried using an associative array to do it at first, but I found it difficult to sort the dates with the sort program. I'll figure it out eventually.
If you have any suggestions email me or send a pull request :).
Footnotes:
I have since implemented what I call "ghetto sorting". It's not pretty but it works