aboutsummaryrefslogtreecommitdiff
path: root/_includes/categories.html
blob: 60a6ed60c6f2122d324b19595170324b6f989c3d (about) (plain) (blame)
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
{% assign articles_with_categories = "" | split:"" %}
{% for article in site.articles %}
  {% if article.lang == page.lang %}
    {% if article.category %}
      {% assign articles_with_categories = articles_with_categories | push:article %}
    {% endif %}
  {% endif %}
{% endfor %}
{% assign articles_with_categories = articles_with_categories | reverse %}

{% assign categories = "" | split:"" %}
{% for article in articles_with_categories %}
  {% assign article_categories = article.category | split:"," %}
  {% for article_category in article_categories %}
    {% assign categories = categories | push:article_category %}
  {% endfor %}
{% endfor %}

{% assign unique_categories = categories | sort | uniq %}
{% for category in unique_categories %}
  <h2 id="{{ category }}">
    <a href="#{{ category }}">{{ category }}</a>:
  </h2>
  <ul>
    {% for article in articles_with_categories %}
      {% assign article_categories = article.category | split:"," %}
      {% for article_category in article_categories %}
        {% if category == article_category %}
          <li>
            <a href="{{ article.url | relative_url }}">{{ article.title | escape }}</a> - {% include i18n-date.html date=article.date %}
          </li>
        {% endif %}
      {% endfor %}
    {% endfor %}
  </ul>
{% endfor %}