Last active
June 15, 2023 22:31
-
-
Save benstraw/408fc197336d271448795a785e73b658 to your computer and use it in GitHub Desktop.
This Liquid loop for Jekyll sorts a collection by date, to reverse the order add ` | reverse`
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 `dogs` | |
* and sorts it by the front matter variable `dob` and than filters | |
* the collection with `reverse` in reverse order | |
* | |
* To make it work I first assigned the data to a new string | |
* called `sorted_dogos`. | |
{% endcomment %} | |
{% assign sorted_dogos = site.dogs | sort: "dob" %} | |
{% for dog in sorted_dogos %} | |
Born: {{ dog.dob | date_to_string: "ordinal", "US" }} | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment