New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting posts in archive.ejs #2153

Closed
oryan opened this Issue Sep 9, 2016 · 5 comments

Comments

3 participants
@oryan

oryan commented Sep 9, 2016

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?

@oryan

This comment has been minimized.

Show comment
Hide comment
@oryan

oryan Sep 11, 2016

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.

oryan commented Sep 11, 2016

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.

@soulteary

This comment has been minimized.

Show comment
Hide comment
@soulteary

soulteary Sep 18, 2016

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 commented Sep 18, 2016

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.

@oryan

This comment has been minimized.

Show comment
Hide comment
@oryan

oryan Sep 18, 2016

@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.

oryan commented Sep 18, 2016

@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.

@tommy351

This comment has been minimized.

Show comment
Hide comment
@tommy351

tommy351 Sep 18, 2016

Member

Hexo uses warehouse for data modeling.

You can see here for available query methods.

Member

tommy351 commented Sep 18, 2016

Hexo uses warehouse for data modeling.

You can see here for available query methods.

@stale stale bot added the wontfix label Sep 27, 2017

@stale

This comment has been minimized.

Show comment
Hide comment
@stale

stale bot Nov 26, 2017

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.

stale bot commented Nov 26, 2017

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.

@stale stale bot added the stale label Nov 26, 2017

@stale stale bot closed this Dec 3, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment