zola icon indicating copy to clipboard operation
zola copied to clipboard

permalink sort order wrong?

Open 1s1y opened this issue 1 year ago • 3 comments

Bug Report

A long article might be split into multiple parts, each with same create_time and different permalink. The primary sort_by is create_time.

e.g.

  • "2022-08-23", "/archives/some-topic-01"
  • "2022-08-24", "/archives/some-topic-02"
  • "2022-08-24", "/archives/some-topic-03"

the sort results dont match the sort order with create_time (asc vs desc).

Environment

Zola version: 0.15.3

Expected Behavior

  • "/archives/some-topic-03"
  • "/archives/some-topic-02"
  • "/archives/some-topic-01"

Current Behavior

  • "/archives/some-topic-02"
  • "/archives/some-topic-03"
  • "/archives/some-topic-01"

1s1y avatar Aug 24 '22 02:08 1s1y

How about change a.permalink.cmp(&b.permalink) to b.permalink.cmp(&a.permalink)?

https://github.com/getzola/zola/blob/7f4060b82a6cdb497363392c5a8be17c9f1007ba/components/content/src/sorting.rs#L22-L43

1s1y avatar Aug 24 '22 02:08 1s1y

Pardon my ignorance in not fully understanding but wouldn't that just invert the problem?

c-git avatar Aug 24 '22 15:08 c-git

Pardon my ignorance in not fully understanding but wouldn't that just invert the problem?

Hmmm, I find a workaround. Just set a RFC3339 date variable like '2022-08-24T12:00:00+08:00' in FrontMatter to overrides the date in filename. Then articles at the same day will be sorted with accurate second.

Although I still think it's better to make permalink sorting direction same with the date variable. If these articles are not related, it doesn't matter how they are sorted. But if related, adjusting the permalink sorting rule can be useful for those who manage article dates by filename.

1s1y avatar Aug 24 '22 16:08 1s1y