diff options
author | Alan Pearce | 2025-03-19 17:41:48 +0100 |
---|---|---|
committer | Alan Pearce | 2025-03-19 17:41:48 +0100 |
commit | 9102aef53c5fb73585359306a518e726a3623731 (patch) | |
tree | ea2b451a527551540f684ece91b18020532e2f1d /internal | |
parent | 896d844cac976afd0ee8aa73dd2fb28e15e7ac79 (diff) | |
download | searchix-9102aef53c5fb73585359306a518e726a3623731.tar.lz searchix-9102aef53c5fb73585359306a518e726a3623731.tar.zst searchix-9102aef53c5fb73585359306a518e726a3623731.zip |
fix: wrong pagination links for combined results
Fixes: https://todo.sr.ht/~alanpearce/searchix/15
Diffstat (limited to 'internal')
-rw-r--r-- | internal/components/results.go | 1 | ||||
-rw-r--r-- | internal/server/mux.go | 8 |
2 files changed, 6 insertions, 3 deletions
diff --git a/internal/components/results.go b/internal/components/results.go index 4f07a78..58fa5ee 100644 --- a/internal/components/results.go +++ b/internal/components/results.go @@ -45,6 +45,7 @@ func Results(r ResultData) g.Node { 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")), ), diff --git a/internal/server/mux.go b/internal/server/mux.go index 2bbff8e..f7a82d8 100644 --- a/internal/server/mux.go +++ b/internal/server/mux.go @@ -82,7 +82,9 @@ func NewMux( return func(w http.ResponseWriter, r *http.Request) { var err error var source *config.Source + var urlBase string if importerType != config.All { + urlBase = "search" source = cfg.Importer.Sources[r.PathValue("source")] if source == nil || importerType != source.Importer { errorHandler(w, r, http.StatusText(http.StatusNotFound), http.StatusNotFound) @@ -151,7 +153,7 @@ func NewMux( if page.Next != 0 { q.Set("page", strconv.Itoa(page.Next)) - tdata.Next = "search?" + q.Encode() + tdata.Next = urlBase + "?" + q.Encode() } if page.Prev != 0 { @@ -160,11 +162,11 @@ func NewMux( } else { q.Set("page", strconv.Itoa(page.Prev)) } - tdata.Prev = "search?" + q.Encode() + tdata.Prev = urlBase + "?" + q.Encode() } q.Set("page", "0") - tdata.All = "search?" + q.Encode() + tdata.All = urlBase + "?" + q.Encode() } w.Header().Add("Cache-Control", "max-age=300") |