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/page.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/page.templ')
-rw-r--r-- | internal/components/page.templ | 26 |
1 files changed, 23 insertions, 3 deletions
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) { <link href={ sheet.URL } rel="stylesheet" integrity={ "sha256-" + sheet.Base64SHA256 }/> } @Unsafe(tdata.ExtraHeadHTML) + <link + rel="search" + type="application/opensearchdescription+xml" + title={ "Searchix " + sourceNameAndType(nil) } + href={ string(joinPath("/all", "opensearch.xml")) } + /> for _, source := range tdata.Sources { <link rel="search" type="application/opensearchdescription+xml" - title={ "Searchix " + sourceNameAndType(*source) } + title={ "Searchix " + sourceNameAndType(source) } href={ string(joinPath("/", source.Importer.String(), source.Key, "opensearch.xml")) } /> } @@ -31,9 +37,19 @@ templ Page(tdata TemplateData) { <header> <nav> <h1><a href="/">Searchix</a></h1> + <a + if tdata.Source == nil { + if tdata.SourceResult != nil || tdata.Query != "" { + class="current" + } + href="/all/search" + } else { + href={ joinPathQuery("/all/search", tdata.Query) } + } + >All</a> for _, source := range tdata.Sources { <a - if tdata.Source.Name == source.Name { + if tdata.Source != nil && tdata.Source.Name == source.Name { class="current" href={ joinPath("/", source.Importer.String(), source.Key, "search") } } else { @@ -65,7 +81,11 @@ func Unsafe(html string) templ.Component { }) } -func sourceNameAndType(source config.Source) string { +func sourceNameAndType(source *config.Source) string { + if source == nil { + return "Combined" + } + switch source.Importer { case config.Options: return source.Name + " " + source.Importer.String() |