Skip to content

Instantly share code, notes, and snippets.

@Chetabahana
Last active October 31, 2019 07:23
Show Gist options
  • Save Chetabahana/25572d8d8fc7cdc25f4e9a3012db9287 to your computer and use it in GitHub Desktop.
Save Chetabahana/25572d8d8fc7cdc25f4e9a3012db9287 to your computer and use it in GitHub Desktop.
This Liquid loop for Jekyll sorts the output of collection by category and weight
---
layout: default
---
{% comment %}
*
* This loop loops through a collection called `feeds` with category 'section'
* and sorts it by the front matter variable 'weight' and than render
* each of the {{ output }} with their own layout
*
* To provide it with an online work you may see the running code here:
* https://github.com/chetabahana/chetabahana.github.io/blob/master/index.html
*
{% endcomment %}{% assign sections = site.feeds | sort: 'weight' | where_exp:"item", "item.category == 'section'" %}
{% for section in sections %}
{{ section.output }}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment