Get the most recent item of a set of pages through it's subdirectories?

I can’t believe I’m asking this.
I have a simple architecture.
image
And I can get all of the packages with this

{% for pkg in site.packages %}
...
{%endfor%}

But I can’t find a simple way to get only the most recent item in each folder. The idea is to make it loose. Create a new folder, add another .md and it should appear with all of them, no manual configuration (similar to how posts work).

I can’t make it, any idea?

Jekyll can’t read the last modified date or created date on a file. I think you could add a date to the front matter and then sort by that.

Or could you use a front matter variable like featured? or does it have to be most recent?

if these were posts then I think you would be able to do it as posts have the date built into them (part of the file name) and liquid knows it is a date. If I remember correctly there may be an issue with dates in the front matter, liquid may think it is a string and then it is hard to sort by? not sure.

Okay, manually setting a date or having the featured sounds good, no problem there. The problem is how can I get only one per folder without hardcoding each folder? or just, how can I get items of each folder?

ah, I see what you are saying. This is a collection right?

in a collection I don’t think the sub folder means anything? if it were a post then it gets picked up as a category.

Check this thread for something similar to what you want sort of. It is a bit old but I think probably still applicable.

also this thought he one above looks pretty close to what you want.