Skip to content
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

How to sort posts in descending order instead of ascending w.r.t Date? #28

Open
ozgunozerk opened this issue Jan 15, 2024 · 2 comments
Open

Comments

@ozgunozerk
Copy link

Afaik, the current template sorts the posts w.r.t their date field: the earliest is the first, the latest is the last.

I want to reverse that order (my latest posts should be the first ones to be displayed).

How can I achieve this?

@ozgunozerk ozgunozerk changed the title How to sort posts in descending order instead of ascending w.r.t Date How to sort posts in descending order instead of ascending w.r.t Date? Jan 15, 2024
@ozgunozerk
Copy link
Author

From what I've seen, there is no ordering. However, since the file name format for posts requires the date, posts are implicitly sorted (not via this template's code).

My current solution is to reverse the post list as such (maybe it will help others as well):

{% if include.show_posts %}
<div class="container animate">
  <div class="row" data-pagebreak="6">
    {% assign reversed_posts = site.crypto | reverse %}
    {% for post in reversed_posts %}
      {% bookshop blog-card post=post %}
    {% endfor %}
  </div>
</div>

It seems like a hacky solution, but if there is no better way, feel free to close this issue.

@adriguerra
Copy link

adriguerra commented Feb 9, 2024

@ozgunozerk Pretty sure that's the way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants