CloudCannon / vonge-jekyll-bookshop-template

📝 Personal blog template for Jekyll

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

ozgunozerk opened this issue · comments

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?

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.

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