Bytes about Bits

Adding short content to this website.

Tagged with: devops, web

Published on

Some weeks ago I added a new form of content to this website: Bits. I added this as a way to overcome the hurdles that come with publishing to a statically hosted site. Each time I wanted to share something I’d have to get my computer[1], open the repo, add a new Markdown file, write the actual content, create a commit, and finally push the commit to the Git remote to trigger the build and deploy pipeline. For some longer posts like the one you are reading right now this is mildly annoying but for a short note about pancakes it’s a blocker. I had to make it easy for me to publish short content on the go, meaning this had to work on my phone without touching Git repositories.

I came up with the following wishlist for my new content and its publisher:

  1. Bits can be notes, links, or quotes.
  2. Bits must be stored alongside the source code of this website as Markdown files and published the same way.
  3. Authoring and storing a bit must be possible on the go.
  4. Authoring, storing and publishing a bit must be as secure as necessary to prevent abuse.
  5. I do not want to manage a server for this.[2]

First, I thought about managing Git repositories and Markdown files on my phone. This would mean I don’t have to write any code or host anything[3]. I quickly abandoned this idea because I’d still have many of the same hurdles that bothered me with my current setup with the addition of having to do everything on a small screen.

So I had to create something new to solve my problem. I wanted to keep my solution minimal while still providing all of the functionality I need. This led me to the following idea.

My user interface would be a simple HTML site with a form and some JavaScript. All of the bit types have some common fields: body, tags, and an optional title. Depending on the type of the bit (note, link, or quote), different inputs are needed. A switcher for the bit type toggles the visibility of the different inputs. For example, selecting the type link adds a URL input to the form. Authentication is handled via a simple password field that is part of the form.

On the backend I would receive the submitted data from the form. After validating the password the data is transformed to Markdown. The Markdown is stored as a file in the website’s Git repository via the GitHub API. From there the website is automatically built and deployed just as it would be when I push manually to the repository.

Finally, I had to think about where this should run. Fortunately, I already host this website on Bunny. More specifically on Bunny CDN serving from a Bunny Storage that stores the website’s files. I just had to do the same thing for the HTML site. For the backend, Bunny also has a solution called edge scripting. This service takes a TypeScript file, puts it behind a domain, and runs it whenever an HTTP request is sent to the domain. Functions run via Deno which natively runs TypeScript and provides a rich standard library. You only pay when the function is used so the costs are kept low.

In the end, I now have a simple way to publish short content to my website. I can now add notes, links, and quotes as I wanted. I manage them like all the other content on this website and I do not have to manage a server. As a bonus point I reduced my cognitive load by using the same platform to host the website and the publisher.


  1. Shockingly, it might not be at the same physical space as I am at that particular moment. ↩︎

  2. I already have too many of them hanging around needing updates and costing money. ↩︎

  3. As anyone who has been doing this software thing for some time knows this is always the preferred option. ↩︎