Order an array with Jekyll / liquid template

后端 未结 3 448
温柔的废话
温柔的废话 2021-01-17 23:46

I\'m trying to do the following. I use Jekyll to create a list of posts, and ordertem by category (monday...sunday) I\'d like to have them displayed in chronological order b

相关标签:
3条回答
  • 2021-01-18 00:10

    It cannot be done without a plugin or custom function. Although, there is an ongoing effort to implement this in the next releases: https://github.com/Shopify/liquid/pull/101 and then it would look like:

    {% for tag in site.tags order:ascending %} 
       ...
    {% endfor %}
    
    0 讨论(0)
  • 2021-01-18 00:11

    simply add reversed in the for statement

     {% for post in site.posts reversed %}
       ...
     {% endfor %}
    
    0 讨论(0)
  • 2021-01-18 00:19

    Ok, not sure it is possible at all to do this kind of sorting, but i've cheated a bit (•__°)

    I just renamed the post that i want to be order with a specific date like:

    0000-00-01-firstpost etc...

    Does it for me for now, but if there is a more clever way to do that, I'm up for it (^___^)

    0 讨论(0)
提交回复
热议问题