mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-12-04 19:08:22 +01:00
dir: Sort by weight, date, and filepath
This commit is contained in:
parent
2a9691f947
commit
636a41126b
6
dir.go
6
dir.go
@ -274,10 +274,12 @@ func (d *Dir) write(dstDir string, task *Task) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// sort sorts the directory's pages by date.
|
||||
// sort sorts the directory's pages by weight, then date, then filepath.
|
||||
func (d *Dir) sort() {
|
||||
sort.Slice(d.Pages, func(i, j int) bool {
|
||||
return d.Pages[i].Date.After(d.Pages[j].Date)
|
||||
pi, pj := d.Pages[i], d.Pages[j]
|
||||
return pi.Weight < pj.Weight || pi.Date.Before(pj.Date) ||
|
||||
pi.FilePath < pj.FilePath
|
||||
})
|
||||
|
||||
for i := range d.Pages {
|
||||
|
Loading…
Reference in New Issue
Block a user