package components import ( "go.alanpearce.eu/searchix/internal/config" "go.alanpearce.eu/searchix/internal/nix" "strconv" ) func convertMatch[I nix.Importable](m nix.Importable) *I { i, ok := m.(I) if !ok { return nil } return &i } templ Results(r ResultData) { if r.Query != "" { if r.Results != nil && r.Results.Total > 0 { if r.Source != nil { switch r.Source.Importer { case config.Options: @Options(r.Results) case config.Packages: @Packages(r.Results) } } else { @Combined(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> if r.Next != r.Prev && r.Results.Total < config.MaxResultsShowAll { <a href={ templ.SafeURL(r.All) }>Show All</a> } </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> } templ openCombinedDialogLink(attr string) { <a class="open-dialog" href={ templ.SafeURL("/" + attr) }>{ attr }</a> }