diff options
author | Alan Pearce | 2024-07-12 20:52:52 +0200 |
---|---|---|
committer | Alan Pearce | 2024-07-12 21:20:15 +0200 |
commit | 6781684647ad7f131054a93e1d13105d865c0e83 (patch) | |
tree | 307a688125f18128f582f7754af9a5451f0cb109 /internal/components/results.templ | |
parent | 442345898802e93b0b884fd0f1c3492e08c34049 (diff) | |
download | searchix-6781684647ad7f131054a93e1d13105d865c0e83.tar.lz searchix-6781684647ad7f131054a93e1d13105d865c0e83.tar.zst searchix-6781684647ad7f131054a93e1d13105d865c0e83.zip |
feat: enable combined search
Diffstat (limited to 'internal/components/results.templ')
-rw-r--r-- | internal/components/results.templ | 19 |
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> +} |