Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make Further Reading display the latest posts. #1699

Merged
merged 2 commits into from
Apr 27, 2024

Conversation

huanyushi
Copy link
Contributor

@huanyushi huanyushi commented Apr 21, 2024

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (refactoring and improving code)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Description

I modified the code in _includes/related-posts.html to enable Further Reading to display the latest posts, as stated in the title.

I need to explain why I made this change.

Consider a scenario where we have five different posts, e.g.

_posts
├─ Title1.md
├─ Title2.md
├─ Title3.md
├─ Title4.md
└─ Title5.md

each of which has the same score calculated in _includes/related-posts.html. When we open any of these posts, Further Reading always displays the three oldest posts instead of the three most recently updated ones.

Before

As an example, when we open Title4 post, It shows Title1, Title2 and Title3,

order2

The same is true when opening Title5. No matter how many posts we write later, it will always display only the first 3 posts.

After

We might prefer it to show the latest 3 posts, e.g. Title2, Title3, Title5. My PR can make the blog produce the following effects:

order1

Additional context

I'm not familiar with Liquid, so these changes were based on my interpretation of the official documentation. There may be other ways to further simplify it, but it does work effectively.

@huanyushi huanyushi changed the title refactor: make Further Reading display the latest articles. refactor: make Further Reading display the latest posts. Apr 21, 2024
Copy link
Owner

@cotes2020 cotes2020 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to add the release date as a sorting factor, putting the match_posts in reverse order will do it.

{% assign match_posts = match_posts | reverse %}

@huanyushi
Copy link
Contributor Author

Thanks for your suggestions, I have already made the modification. If you don't think the theme needs to be changed, you can just close this PR.

@cotes2020 cotes2020 merged commit 796c386 into cotes2020:master Apr 27, 2024
4 of 5 checks passed
@huanyushi huanyushi deleted the Change-order-of-further-reading branch April 28, 2024 07:03
sgn07124 pushed a commit to sgn07124/sgn07124.github.io that referenced this pull request Apr 30, 2024
Copy link

🎉 This PR is included in version 7.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot added the released Included or resolved in the release label May 11, 2024
kimbob13 pushed a commit to kimbob13/kimbob13.github.io that referenced this pull request May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Included or resolved in the release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants