Here's some pseudo-code of what I want to achieve:
for year in post.date
h1 year
for month in post.date
h2 month
ul
li post entry
That's the pseudo-code. However I don't have enough experience to achieve this. The file in which this would happen is this one: https://github.com/Greduan/eduantech.docpad/blob/master/src/documents/posts.html.eco
And it would be in the eco language. I'm using Moment.js as well in case that's necessary.
Even if you don't provide the exact code, a general direction will be very appreciated. :)
EDIT: What I would like to achieve is something similar to this: http://swannodette.github.io/archive.html
EDIT 2: Here's some of the code that I came up with:
for post in @getCollection('posts').toJSON()
for year in post.date
h1 @moment(post.date).format('YYYY')
for month in post.date
h2 @moment(post.date).format('MMMM')
ul ->
li ->
@postDatetime(post.date, 'll') + ' » '
a href:'post.url', post.title
For now it just outputs nothing. So I'm thinking I just got some of the variable names wrong, which I imagine I did. I appreciate any help. :)
BTW don't worry about the @postDatetime
function. That with works no problems somewhere else. :)
If you already have your posts sorted by date, then your collection is already grouped by year,month. All you need to do is loop through the whole collection and insert your year and month headers when the year/month values change. Something like this:
Does that sound like what you are after?