πŸ‘‹ Welcome!

This my personal site where I note down my thoughts. Enjoy!

Formulating Questions

I spent a few hours over the last couple of days upgrading my eleventy setup to "v3.0 canary", and then to tidy up my eleventy config file, taking eleventy-excellent for inspiration. The idea being to move all my added filters, collections and shortcodes to module files.

This worked very well, but there were a couple of filters that simply didn't work. After several hours of failing to get them to work, I relented and decided to ask a question in the eleventy GitHub discussions forum. I took me about 20 minutes to write the question so that I thought it would be clear.

After the third re-reading and final edits, and literally just as I was hovering over the submit button for the final click, the answer jumped out of my text. It was dead simple, a stupid error.

Jim Nielsen's Bulletproof Method to Solving Problems came to mind. I made it right to the very end of Step 1, but not further!

This is what I was going to submit, see if you can spot the problem. πŸ™‚

I have upgraded Eleventy to v3.0 canary which has generally worked very well. So I don't think this is related to that (and probably more to my general lack of knowledge...).

I then moved my custom filters from the eleventy.config.js file to a module file. At this point I got an error for one of the filters.

The filter is creating a URL link to the file on github and looks like this in the eleventy.config.js file:

eleventyConfig.addFilter('pathToGitHub', (localPath) => {
    let baseURL = 'https://github.com/..../blob/master/';
    let outURL =  new URL(localPath,baseURL);
    return outURL;
});

This works fine when using the filter like this in my njk file:

<a href="https://github.com/robindotis/robin.is/blob/master/posts/2024/formulating-questions.md" title="Edit">Edit</a>

But when I then move this filter into a module and import and add the filter like this:

import filters from "./_config/filters.js";
.
.
export default async function(eleventyConfig) {
    eleventyConfig.addFilter("pathToGitHub", filters.folderList);

I get this error when using the filter to create the edit link above:

[11ty] 2. (./_layouts/base.njk)
[11ty]   Template render error: (C:\...\eleventy\robin.is\_includes\footer.njk)
[11ty]   Error: ENOTDIR: not a directory, scandir 'C:\...\eleventy\robin.is\pages\home.njk' (via Template render error)

As such this error makes sense, since page.inputPath is not a path to a directory but a file. What I don't understand is why I get this error when putting the filter in a module, but not when leaving it directly in the eleventy config file.

Some further trial and error indicates that it is not related to the filter code itself, because even if that filter does nothing (eg simply return "/") I get the error. I also don't get the error without using the filter, ie simply using this (which is obviously pointless):

<a href="./posts/2024/formulating-questions.md" title="Edit">Edit</a>

So the error occurs between the output of page.inputPath and before its input into pathToGitHub, but only when that function is in a module. So there is something in the "module" functionality that I am not understanding.

Any suggestions welcome!

Waiting

My daughter was on a trip in Bosnia and had not been feeling well the final two days. So, I had to pick her up at Frankfurt Airport after the return flight.

I was sat outside the arrivals gate, waiting. After the plane had landed it took forever for the display to change to baggage collection. Bored and doom scrolling on my phone, I was waiting for a group of about 40 kids to appear. But my daughter collected her baggage and left as she knew I was already there.

She sent me a text about whether I had a new phone. I wondered how she knew that, maybe somehow from my messages. A few seconds later she sent me this photo:

She'd been sitting next to me for about a minute and I hadn't noticed! 🀣🀣🀣

My excuse is that I got up at 5am to get to the airport for 8am.

Tagged: