/_includes/JB/tags_list

https://bitbucket.org/danshan/blog · #! · 33 lines · 30 code · 3 blank · 0 comment · 0 complexity · 42c02f851a293ab161d4babda3ae7363 MD5 · raw file

  1. {% comment %}<!--
  2. The tags_list include is a listing helper for tags.
  3. Usage:
  4. 1) assign the 'tags_list' variable to a valid array of tags.
  5. 2) include JB/tags_list
  6. example:
  7. <ul>
  8. {% assign tags_list = site.tags %}
  9. {% include JB/tags_list %}
  10. </ul>
  11. Notes:
  12. Tags can be either a Hash of tag objects (hashes) or an Array of tag-names (strings).
  13. The encapsulating 'if' statement checks whether tags_list is a Hash or Array.
  14. site.tags is a Hash while page.tags is an array.
  15. This helper can be seen in use at: ../_layouts/default.html
  16. -->{% endcomment %}
  17. {% if site.JB.tags_list.provider == "custom" %}
  18. {% include custom/tags_list %}
  19. {% else %}
  20. {% if tags_list.first[0] == null %}
  21. {% for tag in tags_list %}
  22. <li><a href="{{ BASE_PATH }}{{ site.JB.tags_path }}#{{ tag }}-ref">{{ tag }} <span>{{ site.tags[tag].size }}</span></a></li>
  23. {% endfor %}
  24. {% else %}
  25. {% for tag in tags_list %}
  26. <li><a href="{{ BASE_PATH }}{{ site.JB.tags_path }}#{{ tag[0] }}-ref">{{ tag[0] }} <span>{{ tag[1].size }}</span></a></li>
  27. {% endfor %}
  28. {% endif %}
  29. {% endif %}
  30. {% assign tags_list = nil %}