2025-12-20 Sat

· rnkn's blog


Implemented a requested feature to keep <details> sidebar menu elements expanded when on that page. Much more difficult than it would seem. The sidebar menu is just Markdown so couldn't be done with HTML. Not possible with CSS. Want to keep the site free from JavaScript.

The solution was to post-process the sidebar HTML with Mojo::DOM, find any <a[href=$slug]> elements, then iterate up over their ancestors for any <details> elements and add the open tag. Also I put on a selected class to allow styling the actual selected link.

Implemented smart typography. "So now I'm able --- to do this!" I love how little code this was. I thought it would be difficult. My main win was using the preexisting recursion counter to only parse the Mojo::DOM at the top-level loop.

last updated: