fix: display albums and artists on the search page, and also few css fixes
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
package views
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/rramiachraf/dumb/data"
|
||||
"github.com/rramiachraf/dumb/utils"
|
||||
)
|
||||
|
||||
templ SearchPage(r data.SearchResults) {
|
||||
@ -14,19 +14,53 @@ templ SearchPage(r data.SearchResults) {
|
||||
<div id="search-results">
|
||||
for _, s := range r.Sections {
|
||||
if s.Type == "song" {
|
||||
<h1>Songs</h1>
|
||||
for _, s := range s.Hits {
|
||||
<a id="search-item" href={ templ.URL(s.Result.Path) }>
|
||||
<img
|
||||
src={ data.ExtractImageURL(s.Result.Thumbnail) }
|
||||
alt={ fmt.Sprintf("%s image", s.Result.Title) }
|
||||
/>
|
||||
<div>
|
||||
<span>{ s.Result.ArtistNames }</span>
|
||||
<h2>{ s.Result.Title }</h2>
|
||||
</div>
|
||||
</a>
|
||||
}
|
||||
<div id="search-section">
|
||||
<h2>Songs</h2>
|
||||
for _, s := range s.Hits {
|
||||
<a id="search-item" href={ templ.URL(s.Result.Path) }>
|
||||
<img
|
||||
src={ data.ExtractImageURL(s.Result.Thumbnail) }
|
||||
alt="Song image"
|
||||
/>
|
||||
<div>
|
||||
<span>{ s.Result.ArtistNames }</span>
|
||||
<h3>{ s.Result.Title }</h3>
|
||||
</div>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
if s.Type == "album" {
|
||||
<div id="search-section">
|
||||
<h2>Albums</h2>
|
||||
for _, a := range s.Hits {
|
||||
<a id="search-item" href={ templ.URL(utils.TrimURL(a.Result.URL)) }>
|
||||
<img
|
||||
src={ data.ExtractImageURL(a.Result.AlbumImage) }
|
||||
alt="Album image"
|
||||
/>
|
||||
<div>
|
||||
<h3>{ a.Result.AlbumName }</h3>
|
||||
</div>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
if s.Type == "artist" {
|
||||
<div id="search-section">
|
||||
<h2>Artists</h2>
|
||||
for _, a := range s.Hits {
|
||||
<a id="search-item" href={ templ.URL(utils.TrimURL(a.Result.URL)) }>
|
||||
<img
|
||||
src={ data.ExtractImageURL(a.Result.ArtistImage) }
|
||||
alt="Artist image"
|
||||
/>
|
||||
<div>
|
||||
<h3>{ a.Result.ArtistName }</h3>
|
||||
</div>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user