Skip to content

Commit

Permalink
perf: include the latest posts in the "Recently Updated" list (mmista…
Browse files Browse the repository at this point in the history
…kes#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.
  • Loading branch information
cotes2020 committed Jan 7, 2024
1 parent 9882244 commit 82d8f2d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions _includes/update-list.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<!-- Get the last 5 posts from lastmod list. -->
<!-- Get 5 last posted/updated posts -->

{% assign MAX_SIZE = 5 %}

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

{% for post in site.posts %}
{% if post.last_modified_at and post.last_modified_at != post.date %}
{% capture elem %}
{{- post.last_modified_at | date: "%Y%m%d%H%M%S" -}}::{{- forloop.index0 -}}
{% endcapture %}
{% assign all_list = all_list | push: elem %}
{% endif %}
{% assign datetime = post.last_modified_at | default: post.date %}

{% capture elem %}
{{- datetime | date: "%Y%m%d%H%M%S" -}}::{{- forloop.index0 -}}
{% endcapture %}

{% assign all_list = all_list | push: elem %}
{% endfor %}

{% assign all_list = all_list | sort | reverse %}
Expand Down

0 comments on commit 82d8f2d

Please sign in to comment.