about summary refs log tree commit diff stats
path: root/internal/server/error.go
diff options
context:
space:
mode:
authorAlan Pearce2024-06-21 13:02:08 +0200
committerAlan Pearce2024-06-21 15:44:12 +0200
commita1dfc548198a1326e71f1dd70303a5d3441f7a39 (patch)
tree03e7d60dc389678ee7cadaac4d5e64596dffde91 /internal/server/error.go
parentcac323d9ae70f55a43fd99b73e60cf614be11797 (diff)
downloadsearchix-a1dfc548198a1326e71f1dd70303a5d3441f7a39.tar.lz
searchix-a1dfc548198a1326e71f1dd70303a5d3441f7a39.tar.zst
searchix-a1dfc548198a1326e71f1dd70303a5d3441f7a39.zip
refactor: switch to templ for HTML templates
Diffstat (limited to 'internal/server/error.go')
-rw-r--r--internal/server/error.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/internal/server/error.go b/internal/server/error.go
index e700d3b..4a8acbc 100644
--- a/internal/server/error.go
+++ b/internal/server/error.go
@@ -3,6 +3,8 @@ package server
 import (
 	"log/slog"
 	"net/http"
+
+	"searchix/internal/components"
 	"searchix/internal/config"
 )
 
@@ -14,9 +16,9 @@ func createErrorHandler(
 		if message == "" {
 			message = http.StatusText(code)
 		}
-		indexData := TemplateData{
+		indexData := components.TemplateData{
 			ExtraHeadHTML: config.Web.ExtraHeadHTML,
-			Sources:       config.Importer.Sources,
+			Sources:       sources,
 			Code:          code,
 			Message:       message,
 		}
@@ -24,9 +26,9 @@ func createErrorHandler(
 		w.Header().Del("Vary")
 		w.WriteHeader(code)
 		if r.Header.Get("Fetch") == "true" {
-			err = templates["error"].ExecuteTemplate(w, "main", indexData)
+			err = components.Error(indexData).Render(r.Context(), w)
 		} else {
-			err = templates["error"].Execute(w, indexData)
+			err = components.ErrorPage(indexData).Render(r.Context(), w)
 		}
 		if err != nil {
 			slog.Error(