all repos — searchix @ 9440d2fc4250e733e1dbe25303bd2407642ff28c

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

refactor: remove unnecessary DocumentData struct
Alan Pearce alan@alanpearce.eu
Fri, 12 Jul 2024 20:54:46 +0200
commit

9440d2fc4250e733e1dbe25303bd2407642ff28c

parent

6781684647ad7f131054a93e1d13105d865c0e83

2 files changed, 6 insertions(+), 16 deletions(-)

jump to
M internal/components/data.gointernal/components/data.go
@@ -4,7 +4,6 @@ import ( 	"go.alanpearce.eu/searchix/frontend"
 	"go.alanpearce.eu/searchix/internal/config"
 	search "go.alanpearce.eu/searchix/internal/index"
-	"go.alanpearce.eu/searchix/internal/nix"
 
 	"github.com/blevesearch/bleve/v2"
 )
@@ -28,9 +27,3 @@ Results        *search.Result 	Prev           string
 	Next           string
 }
-
-type DocumentData struct {
-	TemplateData
-	Document *nix.Importable
-	Children *search.Result
-}
M internal/server/mux.gointernal/server/mux.go
@@ -245,20 +245,17 @@ 				return
 			}
 
-			tdata := components.DocumentData{
-				TemplateData: components.TemplateData{
-					ExtraHeadHTML: cfg.Web.ExtraHeadHTML,
-					Source:        source,
-					Sources:       sources,
-					Assets:        frontend.Assets,
-				},
-				Document: doc,
+			tdata := components.TemplateData{
+				ExtraHeadHTML: cfg.Web.ExtraHeadHTML,
+				Source:        source,
+				Sources:       sources,
+				Assets:        frontend.Assets,
 			}
 			if r.Header.Get("Fetch") == "true" {
 				w.Header().Add("Content-Type", "text/html; charset=utf-8")
 				err = components.Detail(*doc).Render(r.Context(), w)
 			} else {
-				err = components.DetailPage(tdata.TemplateData, *doc).Render(r.Context(), w)
+				err = components.DetailPage(tdata, *doc).Render(r.Context(), w)
 			}
 			if err != nil {
 				log.Error("template error", "template", importerSingular, "error", err)