lyrics

lyrics
git clone git://brookjeynes.dev/bjeynes/lyrics.git
Log | Files | Refs

song-search-table.templ (1239B)


      1 package songsearchtable
      2 
      3 import (
      4 	"fmt"
      5 	"lyrics/internal/domain"
      6 	"lyrics/internal/server/routes"
      7 	"lyrics/internal/server/ui/partials/table"
      8 )
      9 
     10 templ SongSearchTable(params SongSearchTableParams) {
     11 	@table.Table(table.TableParams{
     12 		Headers:     []string{"title", "latin title", "artist", "release"},
     13 		TotalPages:  params.TotalPages,
     14 		CurrentPage: params.CurrentPage,
     15 		GetURL:      fmt.Sprintf("/song/search?query=%s&type=song&limit=%d&format=table", params.Query, params.Limit),
     16 		PushURL:     fmt.Sprintf("/search?query=%s&type=song&limit=%d", params.Query, params.Limit),
     17 	}) {
     18 		for _, song := range params.Songs {
     19 			<tr>
     20 				<th><a href={ routes.Song(song) }>{ song.Title }</a></th>
     21 				if song.LatinTitle != nil {
     22 					<th>{ *song.LatinTitle }</th>
     23 				} else {
     24 					<th></th>
     25 				}
     26 				for idx, artist := range song.Artists {
     27 					<th>
     28 						<a href={ routes.Artist(artist.Artist) }>
     29 							if artist.Role == domain.RolePrimary {
     30 								{ artist.Artist.Name }
     31 								if artist.Artist.LatinName != nil {
     32 									({ *artist.Artist.LatinName })
     33 								}
     34 							}
     35 							if idx < len(song.Artists) - 1 {
     36 								&
     37 							}
     38 						</a>
     39 					</th>
     40 				}
     41 				<th>{ song.ReleaseDate.Format("Jan 2, 2006") }</th>
     42 			</tr>
     43 		}
     44 	}
     45 }