about summary refs log tree commit diff stats
path: root/frontend/templates/blocks
diff options
context:
space:
mode:
authorAlan Pearce2024-05-08 00:15:52 +0200
committerAlan Pearce2024-05-08 00:16:03 +0200
commit973345ad50f9b237714fcb364cf7f665b3909f9d (patch)
tree15225430bd5895b5140df0e301b0e6c3fb5758a8 /frontend/templates/blocks
parentf459e84ecf7307fe2eeb7fbaa5b0c50613ec04f4 (diff)
downloadsearchix-973345ad50f9b237714fcb364cf7f665b3909f9d.tar.lz
searchix-973345ad50f9b237714fcb364cf7f665b3909f9d.tar.zst
searchix-973345ad50f9b237714fcb364cf7f665b3909f9d.zip
feat: paginate search results
Diffstat (limited to 'frontend/templates/blocks')
-rw-r--r--frontend/templates/blocks/options.gotmpl27
-rw-r--r--frontend/templates/blocks/search.gotmpl2
2 files changed, 20 insertions, 9 deletions
diff --git a/frontend/templates/blocks/options.gotmpl b/frontend/templates/blocks/options.gotmpl
index e39d60c..88553b2 100644
--- a/frontend/templates/blocks/options.gotmpl
+++ b/frontend/templates/blocks/options.gotmpl
@@ -1,8 +1,8 @@
-{{- template "results" .Results -}}
+{{- template "results" . -}}
 {{- define "results" }}
-  <div id="results">
-    {{- with . }}
-      {{- range .Results }}
+  {{- if gt .Results.Total 0 }}
+    <section id="results">
+      {{- range .Results.Results }}
         <details id="{{ .Option }}">
           <summary>
             {{ .Option }}
@@ -53,9 +53,20 @@
             {{- end }}
           </dl>
         </details>
-      {{- else }}
-        Nothing found
       {{- end }}
-    {{- end }}
-  </div>
+      <footer>
+        <nav id="pagination">
+          {{- with .Prev }}
+            <a class="button" href="{{ . }}" rel="prev">Prev</a>
+          {{- end }}
+          {{- with .Next }}
+            <a class="button" href="{{ . }}" rel="next">Next</a>
+          {{- end }}
+        </nav>
+        <span> {{ .Results.Total }} results </span>
+      </footer>
+    </section>
+  {{- else }}
+    Nothing found
+  {{- end }}
 {{- end }}
diff --git a/frontend/templates/blocks/search.gotmpl b/frontend/templates/blocks/search.gotmpl
index a4f0ee5..0be63c1 100644
--- a/frontend/templates/blocks/search.gotmpl
+++ b/frontend/templates/blocks/search.gotmpl
@@ -9,7 +9,7 @@
       <button>Search</button>
     </fieldset>
   </form>
-  {{- with .Results }}
+  {{- if .Results }}
     {{ block "results" . }}{{ end }}
   {{- end }}
 {{- end }}