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

image-number-{{ .index }} does not reflect custom sort order when using weights #43

Closed githubmonkey closed 2 years ago

githubmonkey commented 2 years ago

I left a comment on commit 9de0a45668f08acb4a2b691ade80ebae06b3b34b but now I'm not sure if you get notified on this...

I think you introduced a small bug when you added the image_number back. You are using .index, which is set by the caller list.html. However, in that file index is set while resources are still in alphanumerical order, BEFORE they are resorted by weight.

As a result the overview shows images correctly sorted by weight, but the full view uses a different order.

kc0bfv commented 2 years ago

Thanks! I think I got a notification, but I didn't notice it until logging in specifically, whereas this sent me an email (still took me forever to get back to it).

Yup - this bug was actually visible on the "cats" demo site page previously, and I think I saw it several times but I didn't pay enough attention to why the cats were ordered strangely in full image view.

I don't think my fix causes any regressions. I removed the old wrong index totally, but I think it was only being used for gallery sorting and the hash view (ok, one problem with my fix, if someone has a link based on "imagenumber" it may now change... hopefully most direct links are hashes now). Then I reindexed in the loop just before divying up into columns. This also sets indexes for subalbums, but subalbums still won't show up in the full view - they and their index number will just get ignored (still will cause another problem if anyone still has an imagenumber link, but, "in for a penny...").