summaryrefslogtreecommitdiff
path: root/_includes/JB/categories_list
blob: 1f7e45b0cf5e34b0ec2b4ede7a6c2ad868fd4576 (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
35
36
37
{% 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 JB/categories_list
  example:
    <ul>
  	  {% assign categories_list = site.categories %}  
  	  {% include JB/categories_list %}
  	</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 site.JB.categories_list.engine == "custom" %}
  {% include custom/categories_list %}
{% else %}
  {% if categories_list.first[0] == null %}
    {% for category in categories_list %} 
    	<li><a href="{{ BASE_PATH }}{{ site.JB.categories_path }}#{{ category }}-ref">
    		{{ category | join: "/" }} <span>{{ site.categories[category].size }}</span>
    	</a></li>
    {% endfor %}
  {% else %}
    {% for category in categories_list %} 
    	<li><a href="{{ BASE_PATH }}{{ site.JB.categories_path }}#{{ category[0] }}-ref">
    		{{ category[0] | join: "/" }} <span>{{ category[1].size }}</span>
    	</a></li>
    {% endfor %}
  {% endif %}
{% endif %}
{% assign categories_list = nil %}