-
-
Save konstantin-morenko/1c301ad5a6cca6cded99e6726cf2f71a to your computer and use it in GitHub Desktop.
Jekyll: List all categories with according post count and show and link all post items listed in the according category
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>Categories</h2> | |
<ul> | |
{% assign categories_list = site.categories %} | |
{% if categories_list.first[0] == null %} | |
{% for category in categories_list %} | |
<li><a href="#{{ category }}">{{ category | capitalize }} ({{ site.tags[category].size }})</a></li> | |
{% endfor %} | |
{% else %} | |
{% for category in categories_list %} | |
<li><a href="#{{ tag[0] }}">{{ category[0] | capitalize }} ({{ category[1].size }})</a></li> | |
{% endfor %} | |
{% endif %} | |
{% assign categories_list = nil %} | |
</ul> | |
{% for tag in site.categories %} | |
<h3 id="{{ tag[0] }}">{{ tag[0] | capitalize }}</h3> | |
<ul> | |
{% assign pages_list = tag[1] %} | |
{% for post in pages_list %} | |
{% if post.title != null %} | |
{% if group == null or group == post.group %} | |
<li><a href="{{ site.url }}{{ post.url }}">{{ post.title }}<span class="entry-date"><time datetime="{{ post.date | date_to_xmlschema }}" itemprop="datePublished">{{ post.date | date: "%B %d, %Y" }}</time></span></a></li> | |
{% endif %} | |
{% endif %} | |
{% endfor %} | |
{% assign pages_list = nil %} | |
{% assign group = nil %} | |
</ul> | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment