Skip to content

Commit 82d8f2d

Browse files
authored
perf: include the latest posts in the "Recently Updated" list (cotes2020#1456)
Improve the "Recently Updated" list to include the most recent (only one Git commit) posts. This change has two benefits: 1. The post update list is consistent with the git commit timeline. 2. Avoid users not having a list of updates to show when they first publish a site.
1 parent 9882244 commit 82d8f2d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

_includes/update-list.html

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
<!-- Get the last 5 posts from lastmod list. -->
1+
<!-- Get 5 last posted/updated posts -->
22

33
{% assign MAX_SIZE = 5 %}
44

55
{% assign all_list = '' | split: '' %}
66

77
{% for post in site.posts %}
8-
{% if post.last_modified_at and post.last_modified_at != post.date %}
9-
{% capture elem %}
10-
{{- post.last_modified_at | date: "%Y%m%d%H%M%S" -}}::{{- forloop.index0 -}}
11-
{% endcapture %}
12-
{% assign all_list = all_list | push: elem %}
13-
{% endif %}
8+
{% assign datetime = post.last_modified_at | default: post.date %}
9+
10+
{% capture elem %}
11+
{{- datetime | date: "%Y%m%d%H%M%S" -}}::{{- forloop.index0 -}}
12+
{% endcapture %}
13+
14+
{% assign all_list = all_list | push: elem %}
1415
{% endfor %}
1516

1617
{% assign all_list = all_list | sort | reverse %}

0 commit comments

Comments
 (0)