about summary refs log tree commit diff stats
path: root/internal/components/results.templ
diff options
context:
space:
mode:
authorAlan Pearce2024-06-21 16:58:38 +0200
committerAlan Pearce2024-06-21 16:58:38 +0200
commitdbeddced4046cb5756af2604f5cb6734b3e7cee6 (patch)
treedcad7aa9201a6e5a8e97f3f88b7aeadb50c0c330 /internal/components/results.templ
parent107d54a4c4a415f3581a452878cdd625f7f2634a (diff)
downloadsearchix-dbeddced4046cb5756af2604f5cb6734b3e7cee6.tar.lz
searchix-dbeddced4046cb5756af2604f5cb6734b3e7cee6.tar.zst
searchix-dbeddced4046cb5756af2604f5cb6734b3e7cee6.zip
fix: panic rendering results
Diffstat (limited to 'internal/components/results.templ')
-rw-r--r--internal/components/results.templ10
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/components/results.templ b/internal/components/results.templ
index 3953cc3..95c5390 100644
--- a/internal/components/results.templ
+++ b/internal/components/results.templ
@@ -2,9 +2,19 @@ package components
 
 import (
 	"strconv"
+	"log/slog"
 	"searchix/internal/nix"
 )
 
+func convertMatch[I nix.Importable](m nix.Importable) *I {
+	i, ok := m.(I)
+	if !ok {
+		slog.Warn("Converting match failed", "match", m)
+		return nil
+	}
+	return &i
+}
+
 templ Results(r ResultData) {
 	if r.Query != "" {
 		if r.Results != nil && r.Results.Total > 0 {