From 6781684647ad7f131054a93e1d13105d865c0e83 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 12 Jul 2024 20:52:52 +0200 Subject: feat: enable combined search --- internal/components/results.templ | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'internal/components/results.templ') 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) }