From 42a84a3eff09354765ed8d2befaaf431046a4d6d Mon Sep 17 00:00:00 2001 From: huanyushi Date: Sun, 21 Apr 2024 23:07:28 +0800 Subject: [PATCH 1/2] refactor: make Further Reading display the latest articles. --- _includes/related-posts.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/_includes/related-posts.html b/_includes/related-posts.html index ae39da41f17..3fe4c489688 100644 --- a/_includes/related-posts.html +++ b/_includes/related-posts.html @@ -24,7 +24,8 @@ {% assign last_index = match_posts.size | minus: 1 %} {% assign score_list = '' | split: '' %} -{% for i in (0..last_index) %} +{% for j in (0..last_index) %} + {% assign i = last_index | minus: j %} {% assign post = match_posts[i] %} {% if post.url == page.url %} @@ -54,13 +55,15 @@ {% assign index_list = '' | split: '' %} {% if score_list.size > 0 %} - {% assign score_list = score_list | sort | reverse %} + {% assign score_list = score_list | sort_nature | reverse %} {% for entry in score_list limit: TOTAL_SIZE %} {% assign index = entry | split: SEPARATOR | last %} {% assign index_list = index_list | push: index %} {% endfor %} {% endif %} +{% assign index_list = index_list | reverse %} + {% assign relate_posts = '' | split: '' %} {% for index in index_list %} From 0a515c17a511c554fc9ea6f63aaab5a51353647b Mon Sep 17 00:00:00 2001 From: Huanyu Shi <100574401+huanyushi@users.noreply.github.com> Date: Tue, 23 Apr 2024 01:14:07 +0800 Subject: [PATCH 2/2] refactor: make Further Reading output latest posts Signed-off-by: Huanyu Shi <100574401+huanyushi@users.noreply.github.com> --- _includes/related-posts.html | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/_includes/related-posts.html b/_includes/related-posts.html index 3fe4c489688..37a295bdc29 100644 --- a/_includes/related-posts.html +++ b/_includes/related-posts.html @@ -21,11 +21,11 @@ {% assign match_posts = match_posts | push: site.tags[tag] | uniq %} {% endfor %} +{% assign match_posts = match_posts | reverse %} {% assign last_index = match_posts.size | minus: 1 %} {% assign score_list = '' | split: '' %} -{% for j in (0..last_index) %} - {% assign i = last_index | minus: j %} +{% for i in (0..last_index) %} {% assign post = match_posts[i] %} {% if post.url == page.url %} @@ -55,15 +55,13 @@ {% assign index_list = '' | split: '' %} {% if score_list.size > 0 %} - {% assign score_list = score_list | sort_nature | reverse %} + {% assign score_list = score_list | sort | reverse %} {% for entry in score_list limit: TOTAL_SIZE %} {% assign index = entry | split: SEPARATOR | last %} {% assign index_list = index_list | push: index %} {% endfor %} {% endif %} -{% assign index_list = index_list | reverse %} - {% assign relate_posts = '' | split: '' %} {% for index in index_list %}