-
-
- for _, record := range recentlyListenedTracks {
-
-
-
{ record.Track.Name }
-
- for i, artist := range record.Track.Artists {
- if i != 0 {
- if i != len(record.Track.Artists) - 1 {
- and
- } else {
- ,
- }
- }
- { artist.Name }
- }
-
-
{ record.PlayedAt.String() }
-
- }
-
-
+
+
+
}
}
\ No newline at end of file
diff --git a/backseat/components/recentlyListened/index_templ.go b/backseat/components/recentlyListened/index_templ.go
index d104cf0..c208ef6 100644
--- a/backseat/components/recentlyListened/index_templ.go
+++ b/backseat/components/recentlyListened/index_templ.go
@@ -13,6 +13,31 @@ import (
"github.com/zmb3/spotify/v2"
)
+func formatArtistNames(artists []spotify.SimpleArtist) string {
+ var res string
+ for i, artist := range artists {
+ if i != 0 {
+ if i == len(artists)-1 {
+ res += " and "
+ } else {
+ res += ", "
+ }
+ }
+ res += artist.Name
+ }
+ return res
+}
+
+func getSmallestImage(images []spotify.Image) spotify.Image {
+ var smallest *spotify.Image
+ for _, image := range images {
+ if smallest == nil || image.Width < smallest.Width {
+ smallest = &image
+ }
+ }
+ return *smallest
+}
+
func indexPage(recentlyListenedTracks []spotify.RecentlyPlayedItem) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
@@ -46,79 +71,100 @@ func indexPage(recentlyListenedTracks []spotify.RecentlyPlayedItem) templ.Compon
}()
}
ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "