I have a JSON structure built with Hugo listing all posts of each User:
{
"user1": [{
"publishdate": "2021-10-11T00:00:00Z",
"section": "news",
"url": "http://www.example.com/news/another-plain-text/"
}],
"user2": [{
"publishdate": "2021-05-20T00:00:00Z",
"section": "images",
"url": "http://www.example.com/images/gifs/"
}, {
"publishdate": "2021-05-19T00:00:00Z",
"section": "images",
"url": "http://www.example.com/images/external-images/"
}, {
"publishdate": "2021-05-18T00:00:00Z",
"section": "images",
"url": "http://www.example.com/images/local-images/"
}]
}
I'll be using this information to build a chart with Chartist:
const settings = {
// A labels array that can contain any sort of values
labels: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
// Our series array that contains series objects or in this case series data arrays
series: [
[ 5, 30, 21, 14, 7, 20 ]
]
};
However, it proved to be quite a challenge to configure the data like the above example (slightly expanded from Chartist docs) because I don't have entries grouped by weekday and I was trying to avoid having to filter() each entry individually in order to, well, filter, by weekday just so I could count.
How could I, perhaps, expand it into something more usable, in an efficient way? — this example has just a few entries, but that could be hundreds or thousands in a few years.
I know, I should be doing this with Hugo but while it's an incredible tool, slightly more complex theme logics are incredibly difficult to create and Hugo's community is... peculiar.
If you have a more intelligent approach, I'm all ears u.u'