-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathlist-posts
53 lines (40 loc) · 1.9 KB
/
list-posts
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{% comment %}
*
* Possible parameter for this loop:
*
* › entries
* › offset
* › category
* › tag
*
* Example for Category: {% include list-posts entries='3' offset='1' category='design' %}
*
* Example for Tag: {% include list-posts entries='5' tag='terminal' %}
*
*
* This loop works like this:
*
* 1. First we check if there was given a category for filtering › if include.categories == NULL
* 2. If no category is given for filtering do a general loop.
* 3. If a category/tag was given, assign category/tag to the variable category/tag › assign category = include.categories
*
{% endcomment %}
{% assign category = include.category %}
{% assign tag = include.tag %}
<ul class="side-nav">
{% if category == NULL and tag == NULL %}
{% for post in site.posts limit:include.entries offset:include.offset %}
<li><a href="{{ site.url }}{{ site.baseurl }}{{ post.url }}">{% if post.subheadline %}{{ post.subheadline }} · {% endif %}<strong>{{ post.title }}</strong></a></li>
{% endfor %}
<li class="text-right"><a href="{{ site.url }}{{ site.baseurl }}/blog/archive/"><strong>{{ site.data.language.more }}</strong></a></li>
{% elsif category %}
{% for post in site.categories.[category] limit:include.entries offset:include.offset %}
<li><a href="{{ site.url }}{{ site.baseurl }}{{ post.url }}">{% if post.subheadline %}{{ post.subheadline }} · {% endif %}<strong>{{ post.title }}</strong></a></li>
{% endfor %}
<li class="text-right"><a href="{{ site.url }}{{ site.baseurl }}/blog/archive/"><strong>{{ site.data.language.more }}</strong></a></li>
{% elsif tag %}
{% for post in site.tags.[tag] limit:include.entries %}
<li><a href="{{ site.url }}{{ site.baseurl }}{{ post.url }}">{% if post.subheadline %}{{ post.subheadline }} · {% endif %}<strong>{{ post.title }}</strong></a></li>
{% endfor %}
{% endif %}
</ul>