all repos — searchix @ d3336c09a291673ab82e259741bd232baf1bbc07

Search engine for NixOS, nix-darwin, home-manager and NUR users

refactor: extract more pagination logic into module

Alan Pearce
commit

d3336c09a291673ab82e259741bd232baf1bbc07

parent

523d5f2e715f21dd1211c39bc1231d637588902f

1 file changed, 8 insertions(+), 8 deletions(-)

changed files
M internal/components/results.gointernal/components/results.go
@@ -8,11 +8,11 @@ . "alin.ovh/gomponents/html"
) func Results(r ResultData) g.Node { - if r.Query == "" { + if r.Results == nil { return Br() } - if r.Results == nil || r.Results.Total == 0 { + if r.Results.Total == 0 { return Span(Role("status"), g.Text("Nothing found")) }
@@ -34,11 +34,11 @@ Footer(
g.Attr("aria-label", "pagination"), Nav( ID("pagination"), - g.If(r.Prev != "", - A(Class("button"), Href(r.Prev), Rel("prev"), g.Text("Prev")), + g.If(r.SearchNav.Prev != "", + A(Class("button"), Href(r.SearchNav.Prev), Rel("prev"), g.Text("Prev")), ), - g.If(r.Next != "", - A(Class("button"), Href(r.Next), Rel("next"), g.Text("Next")), + g.If(r.SearchNav.Next != "", + A(Class("button"), Href(r.SearchNav.Next), Rel("next"), g.Text("Next")), ), ), Span(
@@ -46,8 +46,8 @@ Role("status"),
g.Textf("%d results", r.Results.Total), ), g.Text(" "), - g.If(r.Next != r.Prev && r.Results.Total < config.MaxResultsShowAll, - A(Href(r.All), g.Text("Show All")), + g.If(r.SearchNav.All != "", + A(Href(r.SearchNav.All), g.Text("Show All")), ), ), })