about summary refs log tree commit diff stats
path: root/internal/server/templates.go
diff options
context:
space:
mode:
authorAlan Pearce2024-05-17 14:06:06 +0200
committerAlan Pearce2024-05-17 14:06:06 +0200
commit05e61978906a08132c4340a5f9ae518134dd0fa9 (patch)
tree0ab5e550a1fe5aaf560459c40eccfdc00e298515 /internal/server/templates.go
parent42611df8133fc88bac5947a65a18fa095d68a951 (diff)
downloadsearchix-05e61978906a08132c4340a5f9ae518134dd0fa9.tar.lz
searchix-05e61978906a08132c4340a5f9ae518134dd0fa9.tar.zst
searchix-05e61978906a08132c4340a5f9ae518134dd0fa9.zip
feat: support searching packages
Diffstat (limited to 'internal/server/templates.go')
-rw-r--r--internal/server/templates.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/server/templates.go b/internal/server/templates.go
index 3d45167..8967599 100644
--- a/internal/server/templates.go
+++ b/internal/server/templates.go
@@ -8,6 +8,7 @@ import (
 	"log/slog"
 	"path"
 	"searchix/frontend"
+	"searchix/internal/config"
 	"searchix/internal/nix"
 	"strings"
 
@@ -33,6 +34,16 @@ var templateFuncs = template.FuncMap{
 
 		return template.HTML(out.String()) // #nosec G203
 	},
+	"sourceNameAndType": func(source config.Source) (string, error) {
+		switch source.Importer {
+		case config.Options:
+			return source.Name + " " + source.Importer.String(), nil
+		case config.Packages:
+			return source.Name, nil
+		default:
+			return "", errors.Errorf("unknown source importer type %s", source.Importer.String())
+		}
+	},
 	"sourceName": func(input string) string {
 		switch input {
 		case "nixos":