Skip to content

Commit 891d407

Browse files
committed
Fix top posts index logic
1 parent b6274cb commit 891d407

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

index.html

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,15 @@
99
<section class="content">
1010

1111
<ul class="listing">
12-
{% for post in site.posts limit:10 %}
13-
<li>
14-
<span>{{ post.date | date_to_string }}</span> <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a>
15-
</li>
16-
{% endfor %}
17-
{% for category in site.categories %}
18-
{% if category[0] == 'top' %}
19-
{% assign posts = category[1] %}
20-
{% for post in posts %}
21-
<li>
22-
<span>{{ post.date | date_to_string }}</span> <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a>
23-
</li>
24-
{% endfor %}
12+
{% assign recent_posts_count = 0 %}
13+
{% for post in site.posts %}
14+
{% comment %}always returns first 10 posts, then only 'top' posts after that'{% endcomment %}
15+
{% if recent_posts_count < 10 or post.categories != null and post.categories contains 'top' %}
16+
<li>
17+
<span>{{ post.date | date_to_string }}</span> <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a>
18+
</li>
2519
{% endif %}
20+
{% assign recent_posts_count = recent_posts_count | plus: 1 %}
2621
{% endfor %}
2722
</ul>
2823

0 commit comments

Comments
 (0)