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/combined.templ | 38 ++++++++++++++++++++++++++++++++++++++ internal/components/data.go | 3 +-- internal/components/page.templ | 26 +++++++++++++++++++++++--- internal/components/results.templ | 19 ++++++++++++++----- 4 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 internal/components/combined.templ (limited to 'internal/components') diff --git a/internal/components/combined.templ b/internal/components/combined.templ new file mode 100644 index 0000000..eeacdb5 --- /dev/null +++ b/internal/components/combined.templ @@ -0,0 +1,38 @@ +package components + +import ( + "go.alanpearce.eu/searchix/internal/index" + "go.alanpearce.eu/searchix/internal/nix" +) + +templ Combined(result *index.Result) { + + + + + + + + + for _, hit := range result.Hits { + + + + + } + +
AttributeDescription
+ @openCombinedDialogLink(nix.GetKey(hit.Data)) + + switch hit.Data.(type) { + case nix.Option: + if o := convertMatch[nix.Option](hit.Data); o != nil { + @markdown(firstSentence(o.Description)) + } + case nix.Package: + if o := convertMatch[nix.Package](hit.Data); o != nil { + { firstSentence(o.Description) } + } + } +
+} diff --git a/internal/components/data.go b/internal/components/data.go index 8f4fe62..601102d 100644 --- a/internal/components/data.go +++ b/internal/components/data.go @@ -11,9 +11,8 @@ import ( type TemplateData struct { Sources []*config.Source - Source config.Source + Source *config.Source Query string - Results bool SourceResult *bleve.SearchResult ExtraHeadHTML string Code int diff --git a/internal/components/page.templ b/internal/components/page.templ index da0322e..ade677f 100644 --- a/internal/components/page.templ +++ b/internal/components/page.templ @@ -18,11 +18,17 @@ templ Page(tdata TemplateData) { } @Unsafe(tdata.ExtraHeadHTML) + for _, source := range tdata.Sources { } @@ -31,9 +37,19 @@ templ Page(tdata TemplateData) {