Skip to content

Instantly share code, notes, and snippets.

@leabs
Last active December 28, 2022 16:36
Show Gist options
  • Save leabs/2542f92a168765b3faa1334c15da929f to your computer and use it in GitHub Desktop.
Save leabs/2542f92a168765b3faa1334c15da929f to your computer and use it in GitHub Desktop.
Display collection data and sort on front matter property based on current page title
<!--Capture page title to use for collection filter on for loop, collection must be listed in the _config.yml to be used as a key pair-->
{% assign thisCollection = page.title | downcase %}
<!--determine the sorted sections to iterate over using front matter-->
{% assign items_grouped = site.[thisCollection] | group_by: 'frontmatterProp' %}
<table class="table table-sm table-responsive">
<thead>
<tr>
<th style="width: 50%; text-align: left;">item name</th>
<th style="width: 50%; text-align: left;">common name</th>
</tr>
</thead>
<tbody>
{% for group in items_grouped %}
<tr>
<td style="text-align: center; font-weight: 700">{{group.name}}</td>
<td style="text-align: center; font-weight: 700"></td>
</tr>
{% for item in group.items %}
<tr>
<td>
<a href="{{item.url}}.html" class="font-italic"
>{{item.name | replace: "&", "."}}</a
>
</td>
<td>{{item.commonName }}</td>
</tr>
{% endfor %} {% endfor %}
</tbody>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment