nunocoracao / blowfish

Personal Website & Blog Theme for Hugo
https://blowfish.page
MIT License
1.26k stars 367 forks source link

✨ Sorting order of recent articles #1556

Open lambertwiddersinn opened 1 month ago

lambertwiddersinn commented 1 month ago

Describe the bug By adding a weight to articles, the recent articles section on home gets sorted by weight instead of date.

Expected behavior It should be ordered by date because it's called recent.

Solution

Add ByDate.Reverse in the partial recent-articles for cardview-fullwidth.html, cardview.html and list.html.

{{ range first $recentArticles (.Paginate (where .Site.RegularPages.ByDate.Reverse "Type" "in" .Site.Params.mainSections)).Pages }}

mnjm commented 1 month ago

Hugo by default lists content by their weights and then by date. https://gohugo.io/templates/lists/#sort-content

What do you think about adding orderByWeight to Recents (and to terms.html for cohesion)? This would allow for configuring order scheme similar to list template in other parts @lambertwiddersinn @nunocoracao

lambertwiddersinn commented 1 month ago

I think it's a good idea to add that to recents and terms for more cohesion. For lists I can choose now the sorting logic by date or weight thanks to your work. It works really well.

nunocoracao commented 1 month ago

I would rather define a default that makes sense instead of adding more configs. It's already pretty bloated.