summaryrefslogtreecommitdiff
path: root/_includes/helpers/categories_list.html
blob: 2ced2d2685ff0e224a78e03884efff75b164ea72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{% comment %}<!--
The categories_list include is a listing helper for categories.
Usage:
  1) assign the 'categories_list' variable to a valid array of tags.
  2) include helpers/categories_list.html.
  example:
    <ul>
  	  {% assign categories_list = site.categories %}  
  	  {% include helpers/categories_list.html %}
  	</ul>
  
  Notes: 
    Categories can be either a Hash of Category objects (hashes) or an Array of category-names (strings).
    The encapsulating 'if' statement checks whether categories_list is a Hash or Array.
    site.categories is a Hash while page.categories is an array.
    
  This helper can be seen in use at: ../_layouts/default.html
-->{% endcomment %}

{% if categories_list.first[0] == null %}
  {% for category in categories_list %} 
  	<li><a href="{{ site.var.categories_path }}#{{ category }}-ref">
  		{{ category | join: "/" }} <span>{{ site.categories[category].size }}</span>
  	</a></li>
  {% endfor %}
{% else %}
  {% for category in categories_list %} 
  	<li><a href="{{ site.var.categories_path }}#{{ category[0] }}-ref">
  		{{ category[0] | join: "/" }} <span>{{ category[1].size }}</span>
  	</a></li>
  {% endfor %}
{% endif %}

{% assign categories_list = null %}