Skip to content

Instantly share code, notes, and snippets.

@namurray
Last active May 3, 2017 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save namurray/b5382ccc0f0840438516706b5e2ba1e5 to your computer and use it in GitHub Desktop.
Save namurray/b5382ccc0f0840438516706b5e2ba1e5 to your computer and use it in GitHub Desktop.
Shopify tag cloud
<ul class="word-cloud">
{% for tag in blogs['BLOG-HANDLE'].all_tags %}
{% assign count = 0 %}
{% for article in blogs[blog.handle].articles %}
{% if article.tags contains tag %}
{% capture count %}{{ count | plus: 1 }}{% endcapture %}
{% endif %}
{% endfor %}
{% assign count = count | plus: 0 %}
<li class="tag-{% if count <= 3 %}alpha
{%elsif count >= 4 and count < 9 %}beta
{%elsif count >= 9 and count < 12 %}gamma
{%elsif count >= 12 and count < 20 %}delta
{%endif%}">
<a href="{{ blog.url }}/tagged/{{ tag | handle }}">{{ tag }}</a>
</li>
{% endfor %}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment