what I want in a static site generator

đź”— posted 2022-02-16

đź”™ back to index

Currently listening to: LLNN — Unmaker

My homegrown static-site generator does not have a feature I want so I ended up not posting at all last year: a tale as old as time. The thing I want is custom elements.

Custom elements are very well supported at this point for modern static site generators—pretty much all of them support using components/elements from some framework or other.

I considered switching away from my homegrown bullshit, I really did. The problem was, in 2020, none of the SSGs I looked at supported components in the way I wanted.

  1. JavaScript in components should be a progressive enhancement, not a requirement, meaning that most things should compile to standard HTML and CSS. Many existing SSGs fail at this.
  2. The component should be able to make asynchronous calls to external processes to build itself at compile time. This ruled out everything else I looked at.

let’s talk about that second requirement a little more.

Here’s something I want to be able to do

Pico sure does look like she's up to something.

<x-squoosh
  src="assets/pico.png"
  width=1200
  height=800
  alt="tabby cat named Pico perched on a floor-to-ceiling cat tree with a mischevious look in her eye"
>
  <x-source
    format="avif"
    quality=30
    effort=4
  />
  <x-source
    format="webp"
    quality=75
    effort=4
  />
  <x-source
    format="mozjpeg"
    quality=75
  />
</x-squoosh>

That element should generate something like this in the final output.

<p>Pico sure does look like she's up to something</p>
<img
  width=1200
  height=800
  srcset="assets/pico.1200w.avif,assets/pico.1200w.webp"
  src="assets/pico.1200w.jpg"
  alt="tabby cat named Pico perched on a floor-to-ceiling cat tree with a mischevious look in her eye"
/>

…but more importantly, it should run the squoosh CLI to build the images (only when necessary! Don’t waste work building stuff that already exists!)

but now it’s the future

In 2020 nothing I looked at had what I wanted1, but it’s 2022 now and I think Astro might fit the bill, or at least be close enough that it won’t annoy me into writing my own thing again.

Not only has the landscape of SSGs changed, I’ve changed, or at least my priorities have. When I put this dang site together in late 2020, my motivation was split between three (conflicting) priorities:

  1. write more words
  2. learn and practice Scala
  3. update my knowledge about FE performance

At this point, I feel satisfied with #3 and I get to satisfy #2 pretty regularly at my day-job at this point, so I don’t really need to incentivize myself to do it within the context of this site—especially since it’s been blocking priority #1!

All that said, I haven’t made the switch yet, so there’s still plenty of opportunity for me to go “lol j/k see you in 2023”.

Footnotes

  1. I wanted to make sure Astro didn’t exist in 2020 so I dug through the commit history and I love this commit showing the pre-public name was magicthing. ↩