Skip to content

Instantly share code, notes, and snippets.

@kyleaparker
Last active November 9, 2020 16:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyleaparker/b108e7142be8ee105f8b to your computer and use it in GitHub Desktop.
Save kyleaparker/b108e7142be8ee105f8b to your computer and use it in GitHub Desktop.
Alphabetical vendor categorization
<ul>
{% assign current = "" %}
{% for product_vendor in shop.vendors %}
{% assign first_letter = product_vendor | strip_html | upcase | truncate: 1, '' %}
{% unless first_letter == current %}
<li class="vendor-letter">{{ first_letter }}</li>
{% endunless %}
<li>{{ product_vendor | link_to_vendor }}</li>
{% assign current = first_letter %}
{% endfor %}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment