feat: replace text/template with templ and refactor code

This commit is contained in:
rramiachraf
2024-03-04 14:59:47 +01:00
parent 5390a2878d
commit e2d5ef044b
43 changed files with 836 additions and 851 deletions

29
views/search.templ Normal file
View File

@ -0,0 +1,29 @@
package views
import "github.com/rramiachraf/dumb/data"
templ SearchPage(r data.SearchResults) {
@layout("Search - dumb") {
<div id="search-page" class="main">
<form method="GET">
<input type="text" name="q" id="search-input" placeholder="Search..." value={ r.Query }/>
</form>
<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) }/>
<div>
<span>{ s.Result.ArtistNames }</span>
<h2>{ s.Result.Title }</h2>
</div>
</a>
}
}
}
</div>
</div>
}
}