Adding Videos to This Blog


Feb 10, 2025
1 minute read

I just added in the ability to render videos in my blog, and in so doing came across a question I hadn't considered before: how do I reserve space for a video that loads after the page does? Also, are videos loaded after page load, or what's the deal there?

Turns out: yes! You can reserve space for a video. In my case, I want my video to take up 100% of the available width and let the height work itself out. So let's use the aspect-ratio property and pre-calculate its value in my template using the video's width and height.

Here's a zola shortcode to do just that:

{%- set path = page.path ~ path -%}
{%- set aspect_ratio = width / height -%}
<video loop autoplay muted
  {%if title%}title="{{ title }}"{%endif%}
  style="aspect-ratio: {{aspect_ratio}}"
>
  <source src="{{ path }}" type="video/mp4">
</video>

Now, to embed a video in my markdown document, I write:

video(title="Progress bar", path="assets/demo.mp4", width=786, height=200)

A tad manual, but it avoids big page reflows so I don't mind.


Recommended reading

Adding Interactivity

Zola is wonderful. It builds quickly, it's extremely configurable, but it is (by design) not well suited for interactive elements or complex JavaScript. I hadn't thought I wanted that until I saw some on Amos's site. He ended up using iframes to manage that integration, which is a perfectly acceptable solution. But it did make me wonder: can we accomplish the same result without all of that nasty ugly HTML? Can we just write some clean JS and call it a day?

Let's find out…

Dynamic Reading Progress Bar

Feb 10, 2025
1 minute read

I'm sure fjall-rs isn't the first tech blog to implement a dynamic reading progress bar, but it's the first the caught my eye. Implementing it was trivially easy, though there are some browser pitfalls to be aware of.