{%- if page.type == 'categories' -%} {%- assign taxonomies = site.categories -%} {%- elsif page.type == 'tags' -%} {%- assign taxonomies = site.tags -%} {%- else -%} {%- assign taxonomies = none -%} {%- endif -%} {%- assign max_count = 0 -%} {%- for taxonomy in taxonomies -%} {%- assign posts = taxonomy[1] -%} {%- if posts.size > max_count -%} {%- assign max_count = posts.size -%} {%- endif -%} {%- endfor -%}
{%- for i in (1..max_count) reversed -%} {%- for taxonomy in taxonomies -%} {%- assign taxonomy_name = taxonomy[0] -%} {%- assign slugified_taxonomy_name = taxonomy_name | slugify -%} {%- assign posts = taxonomy[1] -%} {%- if posts.size == i -%}

{%- if page.type == 'tags' -%} {{ slugified_taxonomy_name }} {%- else -%} {{ taxonomy_name }} {%- endif -%}

{%- endif -%} {%- endfor -%} {%- endfor -%}