about summary refs log tree commit diff stats
path: root/internal/components/results.templ
diff options
context:
space:
mode:
Diffstat (limited to 'internal/components/results.templ')
-rw-r--r--internal/components/results.templ19
1 files changed, 14 insertions, 5 deletions
diff --git a/internal/components/results.templ b/internal/components/results.templ
index 6d85e16..226b71e 100644
--- a/internal/components/results.templ
+++ b/internal/components/results.templ
@@ -3,6 +3,7 @@ package components
 import (
 	"strconv"
 	"go.alanpearce.eu/searchix/internal/nix"
+	"go.alanpearce.eu/searchix/internal/config"
 )
 
 func convertMatch[I nix.Importable](m nix.Importable) *I {
@@ -16,11 +17,15 @@ func convertMatch[I nix.Importable](m nix.Importable) *I {
 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)
+			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">
@@ -50,3 +55,7 @@ templ ResultsPage(r ResultData) {
 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>
+}