@07:51
Progress!
Before:
./data/mentions/3f256ff[...]494.json
./data/mentions/62afe34[...]020.json
...
Hmm, so which file pertains to which post?
{{ $slug := .RelPermalink | sha256 }}
{{ $all_mentions := index site.Data.mentions $slug | default slice }}
{{ $likes := where $all_mentions "wm-property" "like-of" }}
At least the template code to get at it is more or less sane.
During:
./data/mentions/note/8/mentions.json
./data/mentions/note/9/mentions.json
Well, that’s clear as day!
{{ $key := (split path.Dir .RelPermalink) "/" | after 1 | append "mentions" }}
{{ $all_mentions := index site.Data.mentions $key | default slice }}
{{ $likes := where $all_mentions "wm-property" "like-of" }}
What the actual fuck? I want to write {{ index site.Data.mentions .RelPermalink }}
and have done with it. To the data mungery!
Now
./data/mentions/all.json
That’s a tad more opaque, isn’t it? Ah well, there’s always jq
. I can’t see what’s got new mentions from git status any more, but also, I can’t forget to add any new data files either. Call it a win on aggregate.
{{ $all_mentions = index site.Data.mentions.all .RelPermalink | default dict }}
{{ $likes := index $all_mentions "like-of" | default slice }}
Well structured data for the win! And I’m working on eliminating the annoying default dict
and default slice
in that too.