Created
July 24, 2020 12:58
-
-
Save dancingmonkey/c5839832af8628642fdfa74bdd59f863 to your computer and use it in GitHub Desktop.
for loop collections sorted by dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% comment %} | |
* | |
* This loop loops through a collection called `collection_name` | |
* and sorts it by the front matter variable `date` and than filters | |
* the collection with `reverse` in reverse order | |
* | |
* To make it work you first have to assign the data to a new string | |
* called `sorted`. | |
* | |
{% endcomment %} | |
<ul> | |
{% assign sorted = site.collection_name | sort: 'date' | reverse %} | |
{% for item in sorted %} | |
<li>{{ item.title }}</li> | |
{% endfor %} | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment