sort episodes from newest to oldest
This commit is contained in:
9
main.go
9
main.go
@@ -11,6 +11,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"slices"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -387,6 +388,14 @@ func main() {
|
||||
episode.CreatedAt = episode.CreatedAt.In(loc)
|
||||
}
|
||||
|
||||
slices.SortFunc(episodes, func(a, b *Episode) int {
|
||||
if a.CreatedAt.Before(b.CreatedAt) {
|
||||
return 1
|
||||
} else {
|
||||
return -1
|
||||
}
|
||||
})
|
||||
|
||||
tmpl.ExecuteTemplate(w, "podcast.html", struct {
|
||||
Podcast *Podcast
|
||||
Episodes []*Episode
|
||||
|
||||
Reference in New Issue
Block a user