Added layout for multiple categories

Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
Jim Martens 2017-12-25 15:06:45 +01:00
parent 580f394eed
commit d3027d91b0
1 changed files with 23 additions and 0 deletions

23
_layouts/categories.html Normal file
View File

@ -0,0 +1,23 @@
---
layout: default
---
{{ content }}
<ul class="post-list list-unstyled">
{% assign categories = page.categories | split:',' %}
{% assign posts = site.categories[categories.first] %}
{% for category in categories %}
{% if category != categories.first %}
{% assign posts = site.categories[category] | concat: posts %}
{% endif %}
{% endfor %}
{% assign posts = posts | sort: 'date' | reverse %}
{% for post in posts %}
<li class="mb-4">
<span class="small text-muted">{{ post.date | date: "%b %-d, %Y" }}</span>
<p class="h4 post-title">
<a class="post-link" href="{{ post.url | absolute_url }}">{{ post.title }}</a>
</p>
</li>
{% endfor %}
</ul>