|
| 1 | +--- |
| 2 | +layout: page |
| 3 | +# All the Categories of posts |
| 4 | +--- |
| 5 | + |
| 6 | +{% include lang.html %} |
| 7 | + |
| 8 | +{% assign HEAD_PREFIX = 'h_' %} |
| 9 | +{% assign LIST_PREFIX = 'l_' %} |
| 10 | + |
| 11 | +{% assign group_index = 0 %} |
| 12 | + |
| 13 | +{% assign sort_categories = site.categories | sort %} |
| 14 | + |
| 15 | +{% for category in sort_categories %} |
| 16 | + {% assign category_name = category | first %} |
| 17 | + {% assign posts_of_category = category | last %} |
| 18 | + {% assign first_post = posts_of_category | first %} |
| 19 | + |
| 20 | + {% if category_name == first_post.categories[0] %} |
| 21 | + {% assign sub_categories = '' | split: '' %} |
| 22 | + |
| 23 | + {% for post in posts_of_category %} |
| 24 | + {% assign second_category = post.categories[1] %} |
| 25 | + {% if second_category %} |
| 26 | + {% unless sub_categories contains second_category %} |
| 27 | + {% assign sub_categories = sub_categories | push: second_category %} |
| 28 | + {% endunless %} |
| 29 | + {% endif %} |
| 30 | + {% endfor %} |
| 31 | + |
| 32 | + {% assign sub_categories = sub_categories | sort %} |
| 33 | + {% assign sub_categories_size = sub_categories | size %} |
| 34 | + |
| 35 | + <div class="card categories"> |
| 36 | + <!-- top-category --> |
| 37 | + <div |
| 38 | + id="{{ HEAD_PREFIX }}{{ group_index }}" |
| 39 | + class="card-header d-flex justify-content-between hide-border-bottom" |
| 40 | + > |
| 41 | + <span class="ms-2"> |
| 42 | + <i class="far fa-folder{% if sub_categories_size > 0 %}-open{% endif %} fa-fw"></i> |
| 43 | + |
| 44 | + {% capture _category_url %}/categories/{{ category_name | slugify | url_encode }}/{% endcapture %} |
| 45 | + <a href="{{ _category_url | relative_url }}" class="mx-2">{{ category_name }}</a> |
| 46 | + |
| 47 | + <!-- content count --> |
| 48 | + {% assign top_posts_size = site.categories[category_name] | size %} |
| 49 | + <span class="text-muted small font-weight-light"> |
| 50 | + {% if sub_categories_size > 0 %} |
| 51 | + {{ sub_categories_size }} |
| 52 | + {% if sub_categories_size > 1 %} |
| 53 | + {{ |
| 54 | + site.data.locales[lang].categories.category_measure.plural |
| 55 | + | default: site.data.locales[lang].categories.category_measure |
| 56 | + }} |
| 57 | + {% else %} |
| 58 | + {{ |
| 59 | + site.data.locales[lang].categories.category_measure.singular |
| 60 | + | default: site.data.locales[lang].categories.category_measure |
| 61 | + }} |
| 62 | + {% endif -%} |
| 63 | + , |
| 64 | + {% endif %} |
| 65 | + |
| 66 | + {{ top_posts_size }} |
| 67 | + |
| 68 | + {% if top_posts_size > 1 %} |
| 69 | + {{ |
| 70 | + site.data.locales[lang].categories.post_measure.plural |
| 71 | + | default: site.data.locales[lang].categories.post_measure |
| 72 | + }} |
| 73 | + {% else %} |
| 74 | + {{ |
| 75 | + site.data.locales[lang].categories.post_measure.singular |
| 76 | + | default: site.data.locales[lang].categories.post_measure |
| 77 | + }} |
| 78 | + {% endif %} |
| 79 | + </span> |
| 80 | + </span> |
| 81 | + |
| 82 | + <!-- arrow --> |
| 83 | + {% if sub_categories_size > 0 %} |
| 84 | + <a |
| 85 | + href="#{{ LIST_PREFIX }}{{ group_index }}" |
| 86 | + data-bs-toggle="collapse" |
| 87 | + aria-expanded="true" |
| 88 | + aria-label="{{ HEAD_PREFIX }}{{ group_index }}-trigger" |
| 89 | + class="category-trigger hide-border-bottom" |
| 90 | + > |
| 91 | + <i class="fas fa-fw fa-angle-down"></i> |
| 92 | + </a> |
| 93 | + {% else %} |
| 94 | + <span data-bs-toggle="collapse" class="category-trigger hide-border-bottom disabled"> |
| 95 | + <i class="fas fa-fw fa-angle-right"></i> |
| 96 | + </span> |
| 97 | + {% endif %} |
| 98 | + </div> |
| 99 | + <!-- .card-header --> |
| 100 | + |
| 101 | + <!-- Sub-categories --> |
| 102 | + {% if sub_categories_size > 0 %} |
| 103 | + <div id="{{ LIST_PREFIX }}{{ group_index }}" class="collapse show" aria-expanded="true"> |
| 104 | + <ul class="list-group"> |
| 105 | + {% for sub_category in sub_categories %} |
| 106 | + <li class="list-group-item"> |
| 107 | + <i class="far fa-folder fa-fw"></i> |
| 108 | + |
| 109 | + {% capture _sub_ctg_url %}/categories/{{ sub_category | slugify | url_encode }}/{% endcapture %} |
| 110 | + <a href="{{ _sub_ctg_url | relative_url }}" class="mx-2">{{ sub_category }}</a> |
| 111 | + |
| 112 | + {% assign posts_size = site.categories[sub_category] | size %} |
| 113 | + <span class="text-muted small font-weight-light"> |
| 114 | + {{ posts_size }} |
| 115 | + |
| 116 | + {% if posts_size > 1 %} |
| 117 | + {{ |
| 118 | + site.data.locales[lang].categories.post_measure.plural |
| 119 | + | default: site.data.locales[lang].categories.post_measure |
| 120 | + }} |
| 121 | + {% else %} |
| 122 | + {{ |
| 123 | + site.data.locales[lang].categories.post_measure.singular |
| 124 | + | default: site.data.locales[lang].categories.post_measure |
| 125 | + }} |
| 126 | + {% endif %} |
| 127 | + </span> |
| 128 | + </li> |
| 129 | + {% endfor %} |
| 130 | + </ul> |
| 131 | + </div> |
| 132 | + {% endif %} |
| 133 | + </div> |
| 134 | + <!-- .card --> |
| 135 | + |
| 136 | + {% assign group_index = group_index | plus: 1 %} |
| 137 | + {% endif %} |
| 138 | +{% endfor %} |
0 commit comments