Tech Stack to Write a Book

I wrote Alter-Nomad using Markdown and Pandoc. That's the tech stack I found after researching how to write a book using Markdown.

The benefits are nice: Markdown allows me to focus on the content rather than the way it looks, it's easy to manage the different drafts using Git versioning, and Pandoc makes it easy to obtain a finished product in a single command line. It was nice and easy to use, and it did the job.

The problem is that it's quite hard to customize. Pandoc uses a Latex generator to generate references, and it uses Cascading Style Sheets to design the resulting files.

I had a much better idea two days ago.

If you think about it, an ebook is basically a Progressive Web App: you want to be able to read it both offline and online, and it has to be generated from code to ease the writing process. The idea is to use a static file generator like GatsbyJS to write, version, publish, and compile a rich ebook.

Each section of the book is written in Markdown. References are injected at build time using Markdown variables and a custom helper function. Styling is handled using SaSSified CSS. NodeJS is used to output HTML by GatsbyJS, and thus we can use this HTML coupled with our custom CSS to create rich PDF, mobi, and epub files.

It's quite the developer's dream I think, so I'm going to release my custom config as an open-source GatsbyJS starter for everyone to use once I'm done implementing it.