Today's accomplishment:
Got #hugo to *actually* include JS correctly depending on page.Store settings from shortcodes.
You can define "shortcodes" in Hugo for things like "insert a video player here". So when I say `{{< video "foo" >}}` it'll insert whatever HTML I've defined for playing the "foo" video. The problem is that most of the interesting things that you can do with shortcodes (video, echarts, mermaid, etc) need Javascript to work. So the usual pattern is that the shortcode template calls something like `{{ .Page.Store.Set "hasMermaid" true }}` and then the include-all-the-Javascript template only includes the JS if `.Page.Store.Get "hasMermaid"` is true, so you don't end up adding extra JS all over the place.
It worked fine for each individual post's page (/post/YYYY/MM/DD/foo/) but not for / or /page/X/. So any time I put a JS-needing shortcode above the fold on a post, it failed to render correctly.
I'm not entirely sure how I broke it, but something about the way I was doing summaries kept .Store from propagating right, so none of the logic that used page.Store.Get(...) thought that the feature was used on the page, so none of the JS was included, breaking charts and video.
Reverting my article-summary changes fixed .Store propagation (but looked ugly), and then it was just a matter of walking through it line by line to see which line broke it. I ended up reverting to `{{- with .Markup "home" -}}{{- with .Render -}}` instead of `{{- .Summary -}}`. The generated HTML is identical, but .Store works now. And I have a headache, after a total of about 5 hours looking into this.
I'm impressed with how far Hugo can push Go's text templates, but... maybe that wasn't the best way to implement something this complicated?