diff options
-rw-r--r-- | internal/components/options.templ | 4 | ||||
-rw-r--r-- | internal/components/packages.templ | 4 | ||||
-rw-r--r-- | internal/components/results.templ | 10 |
3 files changed, 16 insertions, 2 deletions
diff --git a/internal/components/options.templ b/internal/components/options.templ index ce3ffff..44bc5a3 100644 --- a/internal/components/options.templ +++ b/internal/components/options.templ @@ -15,7 +15,9 @@ templ Options(result *index.Result) { </thead> <tbody> for _, hit := range result.Hits { - @optionRow(hit.Data.(nix.Option)) + if m := convertMatch[nix.Option](hit.Data); m != nil { + @optionRow(*m) + } } </tbody> </table> diff --git a/internal/components/packages.templ b/internal/components/packages.templ index 4e00a5a..e811220 100644 --- a/internal/components/packages.templ +++ b/internal/components/packages.templ @@ -16,7 +16,9 @@ templ Packages(result *index.Result) { </thead> <tbody> for _, hit := range result.Hits { - @packageRow(hit.Data.(nix.Package)) + if m := convertMatch[nix.Package](hit.Data); m != nil { + @packageRow(*m) + } } </tbody> </table> 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 { |