Skip to content

Instantly share code, notes, and snippets.

@zakhardage
Last active December 18, 2015 03:39
Show Gist options
  • Save zakhardage/5719933 to your computer and use it in GitHub Desktop.
Save zakhardage/5719933 to your computer and use it in GitHub Desktop.
Archives widget for shopify blog sidebar
{% capture dates %}2013 2014 2015 2016 2017 2018 2019 2020{% endcapture %}
{% capture tags %}{% for tag in blog.all_tags %}{{ tag }} {% endfor %}{% endcapture %}
<div id="categories" class="widget">
<h2>Categories</h2>
{% for tag in blog.all_tags %}
{% assign check = tag | downcase | split:' ' %}
{% unless dates contains check[0] %}
<a href="{{ blog.url }}/tagged/{{ tag | handle }}">{{ tag }}</a>
{% endunless %}
{% endfor %}
</div> <!-- end #categories -->
<div id="archives" class="widget">
<h2>Archives</h2>
{% if tags contains '2015' %}
<span>2015</span>
{% for tag in blog.all_tags reversed %}
{% assign check = tag | downcase | split:' ' %}
{% if dates contains check[0] and check[0] == '2015' %}
<a href="{{ blog.url }}/tagged/{{ tag | handle }}">{{ check[1] }}</a>
{% endif %}
{% endfor %}
{% endif %}
{% if tags contains '2014' %}
<span>2014</span>
{% for tag in blog.all_tags reversed %}
{% assign check = tag | downcase | split:' ' %}
{% if dates contains check[0] and check[0] == '2014' %}
<a href="{{ blog.url }}/tagged/{{ tag | handle }}">{{ check[1] }}</a>
{% endif %}
{% endfor %}
{% endif %}
{% if tags contains '2013' %}
<span>2013</span>
{% for tag in blog.all_tags reversed %}
{% assign check = tag | downcase | split:' ' %}
{% if dates contains check[0] and check[0] == '2013' %}
<a href="{{ blog.url }}/tagged/{{ tag | handle }}">{{ check[1] }}</a>
{% endif %}
{% endfor %}
{% endif %}
</div> <!-- end #archives -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment