kc0bfv / autophugo

AutoPhugo [ˌɔtoʊˈfjuːgəʊ] is a gallery/photoblog theme for Hugo that's a little more automatic than Phugo.
Other
97 stars 56 forks source link

Added support for ordering albums on front page #44

Closed ultraflynn closed 2 years ago

ultraflynn commented 2 years ago

I wanted to add the capability to order the albums on the front page based on the dates. Default is to order ByDate with the oldest first at the top which means that viewers have to scroll all the way to the bottom to get the latest albums. I wanted to provide a simple switch to reverse that order (using ByDate.Reverse) based on configuration by adding a "sort_order" to the site parameters. Default value is "oldest_first" which mirrors the current behaviour. Setting this to "newest_first" places the latest albums at the top of the page.

Also updated the README and both example sites with the configuration example commented out in the same style as the other unused configuration parameters.

kc0bfv commented 2 years ago

Hrm - date is a default sort just because it's something. Date doesn't actually get used for anything else.

The actual sort method that's used is a little after this part in list.html (line 56) - it's by weight. The weight should be specified in the frontmatter of the album if you want to sort your subalbums. The benefit of that method is that it can also work for the images, which can have weights specified in the resources section of the frontmatter, but don't ever get dates automatically (unfortunately I can't pull like a file date or anything from the images).

Since the date doesn't actually get used for anything, you don't even need to specify it or make sure it's correct/close.

I don't really want to introduce an additional sorting method unless it can apply to everything in the same way, I think that would get confusing, and I don't think it provides significant benefit over the weights method. I will add "weight" to the default archetype so folks have less typing - it's mentioned in the Readme already.

ultraflynn commented 2 years ago

Thanks for the review. I'm adding lots of albums in random date order which is why I wanted it automatically date sorted. I understand what you mean about the weight though. For my use case having to change all the weights to order correctly by date is an overhead (not a huge one I'll grant you).

Feel free to reject the PR.