Fighting with Eleventy

Over at daily.baty.net, I’ve been trying to wrangle Eleventy into showing the posts I want on the home page, in the order I want them. I’ve completely failed so far and it’s very frustrating. I don’t think this is at all the fault of Eleventy. I’m just really slow to pick up new things.

I have two tag-based “collections” in Eleventy: Journal and Post. I’ve always only shown “collections.journal” on the home page but I wanted to include regular blog posts, too. Do you think I can figure out how to do that? Nope. The closest I’ve come is to create a custom collection like so:

eleventyConfig.addCollection("myHomeCollection", function(collectionApi) {
        const journals = collectionApi.getFilteredByTags("journal");
        const posts = collectionApi.getFilteredByTags("post");
        return allHomePosts = [...journals,...posts];

This gets me the correct set of posts, but they’re sorted first by tag and then by date, so it’s unusable on the home page. I want reverse-chronological over the entire array but I’ve no idea how to do that. I’m so dense.

In the template, I use the reverse filter, {% for post in postslist | reverse %}, but no joy. What the heck am I doing wrong here?

Eleventy and my Daily Notes

Somehow, for reasons unknown, I’ve rebuilt daily.baty.net using Eleventy.

It started when I struggled to make some tweaks to the site, which is (was) generated using Tinderbox. Tinderbox, being Tinderbox, is ridiculously powerful and flexible, but it wasn’t doing what I thought I was telling it to do. So I stepped away and started tinkering with its inspiration, my Drummer blog. For a hot minute, I considered going back to using Drummer, even though I worry about its longevity. Drummer is how blogging is supposed to work (at least in my head), so I started looking at it again.

Then Twitter decided to shut off its free API, which Drummer depends on for identity. Thankfully, Dave is working on a path around the Twitter problem, but in the meantime has temporarily shut down Drummer.

While I waited, I wondered if instead, I could make Hugo look and work like my Tinderbox blog, but I quickly realized that I’m never going to understand Hugo’s templating process/language enough to do anything clever with it.

What about Eleventy? I’d never really considered Eleventy but I know some people really like it. When I saw that they had recently announced the v2.0 (beta), I figured it was a good time to see what it was all about.

The short answer is that I like it! I found the basics much easier to grok than Hugo. I had a simple blog put together in a couple of hours. It was one of those incremental things where I experienced small, early wins, so I was encouraged to continue.

I pulled the (admittedly outdated) CSS and markup from my Tinderbox templates and shoehorned them into Nunjucks files. It was surprisingly easy, so I kept going and was so successful that within a few more hours I’d decided to go all-in and now daily.baty.net is running Eleventy. Good times!