Today's The Day - Let's Sort Sorting

This blog section has been running for far too long with all index pages displaying articles from oldest to newest... That changes today.

The thoughts and things index page has been displaying those thoughts and things in chronological order... That would make sense if you were reading my thoughts from start to end like a book. But perhaps you just want to know the most recent nugget of knowledge I've imparted. Let's fix that.

Here's the issue:

I can see two main ways to approach this problem:

  1. Assume that I'm a fool, and I've done something silly and debug my own code some more until I find the dumb mistake I've made.
  2. Dive even deeper into Nuxt Content's built in systems and components, until I can articulate the reason why things aren't working the way I had anticipated. Perhaps reasoning why someone made it this way... Maybe even being able to reason with a way to fix the issue via their github?
  3. Circumvent the entire issue and implement the rendering of things myself, given that I know I can run the content query manually and get the contents in the order I expected. Knowing that I may be missing out on valuable built in logic.

In all honesty I'm probably going to take a shotgun approach to resolving this issue and try a bit of each option to feel out which is the path of least resistance / greatest profit.

Progress update 1

In trying to demonstrate the issue I decided to try inlining a ContentNavigation into this post using the same query parameters but limiting the number of posts:

This has resulted in a list of posts, limited to a count of 4... Specifically taking the newest 4 posts! WHAT?!

Ok... So the posts are actually being queried for in descending date order, but actually returned from the query in ascending date order. Why? What? Why?

So far I've mostly been trying option 1; verifying that I'm not just a fool.

Deeper dive

My next move is to start the deeper dive. There's no better place to start than the start. So... Let's read the contend module's docs on self-managed navigation to see if it gives any insights...

The first thing I spot is this:

Based on the generated _id and _path keys, Nuxt Content generates a whole navigation structure for your content.

Which gets me wondering whether the output for fetchContentNavigation will always be reliant on the generated _id field for the order of output.

Unfortunate wrap up..

Ok... I didn't get it done today, but I think I will tomorrow. I overestimated the amount of time I would have to work with, but I'll have a full days work tomorrow to get to the bottom of this. Just you wait and see.