{% for cat, articles in categories|sort %}
{% if (article and article.category == cat) or category == cat %}
- {{ cat | upper }}
{% for art in articles | sort(attribute="date") %}
{% if article == art %}
- {{ art.title }}
{% else %}
- {{ art.title }}
{% endif %}
{% endfor %}
{% else %}
- {{ cat | upper }}
{% endif %}
{% endfor %}