I've tried searching through the documentation to no avail.
How would one sort the posts in reverse?
My theme has this:
<% page.posts.each(function(post, i){ %>
<%- partial('archive-post', {post: post }) %>
<% }) %>
I've tried a few things including this:
<%- partial('archive-post', {post: post, orderby: "date", order: -1 }) %>
and also this:
<% page.posts.sort('date', -1).each(function(post, i){ %>
<%- partial('archive-post', {post: post }) %>
<% }) %>
Any ideas on how I can sort my posts so that the oldest is always the first in the list?
This seems to work.
<% page.posts.sort('date', 1).each(function(post, i){ %>
<%- partial('archive-post', {post: post }) %>
<% }) %>
It would be awesome if you could explain the way these types of functions work in the documentation. It's currently pretty difficult to figure out how basic theming functions work.
Maybe you should add date prefix for each posts, if you won't like date prefix in permalink, you can use alias rewrite it.
The template will used to render each posts, i don't think it's good idea, if you sorting post in template and you have a lot of posts.
@soulteary I'm sorry, I'm afraid I don't understand what you are suggesting.
My issue has nothing to do with generating permalinks, aliases, or rendering posts.
This issue has been automatically marked as stale because lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
This seems to work.
It would be awesome if you could explain the way these types of functions work in the documentation. It's currently pretty difficult to figure out how basic theming functions work.