blob: 3953cc34159d2c99bb8c87750640ac27c287b2f3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
package components
import (
"strconv"
"searchix/internal/nix"
)
templ Results(r ResultData) {
if r.Query != "" {
if r.Results != nil && r.Results.Total > 0 {
switch r.Results.Hits[0].Data.(type) {
case nix.Option:
@Options(r.Results)
case nix.Package:
@Packages(r.Results)
}
<footer aria-label="pagination">
<nav id="pagination">
if r.Prev != "" {
<a class="button" href={ templ.SafeURL(r.Prev) } rel="prev">Prev</a>
}
if r.Next != "" {
<a class="button" href={ templ.SafeURL(r.Next) } rel="next">Next</a>
}
</nav>
<span role="status">{ strconv.FormatUint(r.Results.Total, 10) } results</span>
</footer>
} else {
<span role="status">Nothing found</span>
}
} else {
<br/>
}
}
templ ResultsPage(r ResultData) {
@SearchPage(r.TemplateData, r) {
@Results(r)
}
}
templ openDialogLink(attr string) {
<a class="open-dialog" href={ templ.SafeURL(attr) }>{ attr }</a>
}
|