sort episodes from newest to oldest

This commit is contained in:
2026-02-17 20:23:38 +03:00
parent e4c4cdce41
commit 44c7126ac5

View File

@@ -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