welpo / tabi

A modern Zola theme with search, multilingual support, optional JavaScript, a perfect Lighthouse score, and a focus on accessibility.
https://welpo.github.io/tabi/
MIT License
97 stars 32 forks source link

Feature suggestion: sort-order setting for Tags listing page #341

Closed metaleap closed 4 days ago

metaleap commented 5 days ago

For some sites, it would be desirable if a tags listing page such as this could be set to sort the tags not alphabetically but by number-of-items (descending). This brings the "most focused-on topics on this site" right to the top, with the "less-relevant / misc / side show topics" right at the bottom.

welpo commented 5 days ago

Makes sense! We would need to modify taxonomy_list.html.

I'm thinking a variable like tag_sorting with two options: name or frequency.

Would you be interested in creating a PR?

metaleap commented 5 days ago

Well alright I'm gonna give it a shot, stay tuned

welpo commented 5 days ago

Great! Don't hesitate to reach out or open an incomplete PR. I'll happily assist wherever possible.

metaleap commented 5 days ago

Eh, I don't get it. Even just changing {%- for term in terms -%} to {%- for term in terms | reverse -%} or {%- for term in terms | reverse() -%} doesn't change the sorting. Even after hard-restarting zola serve.

Of course reverse-alphabetical wouldn't be the final desired sorting, but this was just a first attempt and already a total lack of visible result is laughing in my face.. any ideas? — short of having to grind through all of keats.github.io/tera/docs :grin:

welpo commented 5 days ago

My bad!

Your code is correct. I linked one of the files that need modifying. The template that handles tags is: https://github.com/welpo/tabi/blob/main/templates/tags/list.html

Sorry~

metaleap commented 4 days ago

Thank you! Got it working, PR incoming.