all repos — searchix @ 6781684647ad7f131054a93e1d13105d865c0e83

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: enable combined search

Alan Pearce
commit

6781684647ad7f131054a93e1d13105d865c0e83

parent

442345898802e93b0b884fd0f1c3492e08c34049

1 file changed, 23 insertions(+), 3 deletions(-)

changed files
M internal/components/page.templinternal/components/page.templ
@@ -18,11 +18,17 @@ for _, sheet := range tdata.Assets.Stylesheets {
<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 @@ <body>
<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 @@ return
}) } -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()