Files
soundcloak/templates/featured.templ
2025-02-03 19:43:16 +02:00

46 lines
1.4 KiB
Plaintext

package templates
import (
"git.maid.zone/stuff/soundcloak/lib/sc"
"net/url"
"strconv"
)
templ FeaturedTracks(p *sc.Paginated[*sc.Track]) {
<h1>Featured Tracks</h1>
if len(p.Collection) == 0 {
<p>no more tracks</p>
} else {
for _, track := range p.Collection {
@TrackItem(track, true, "")
}
if p.Next != "" {
<a class="btn" href={ templ.SafeURL("/_/featured?pagination=" + url.QueryEscape(p.Next[sc.H+len("/featured_tracks/top/all-music"):])) } rel="noreferrer">more tracks</a>
}
}
}
templ Discover(p *sc.Paginated[*sc.Selection]) {
<h1>Discover Playlists</h1> // also tracks apparently? haven't seen any
<span>Got { strconv.FormatInt(int64(len(p.Collection)), 10) } selections</span>
if len(p.Collection) != 0 {
for _, selection := range p.Collection {
// skip so we don't just include the title and zero playlists with it
if len(selection.Items.Collection) == 0 {
{{ continue }} // raw go code my beloved
}
<h2>{selection.Title}</h2>
for _, pl := range selection.Items.Collection {
// We don't need the username
@PlaylistItem(pl, false)
}
}
// I don't think they have pagination for this endpoint, just leaving this here, in case they actually do
// if p.Next != "" {
// <a class="btn" href={ templ.URL("/discover?pagination=" + url.QueryEscape(strings.Split(p.Next, "/discover")[1])) } rel="noreferrer">more playlists</a>
// }
}
}