use latest templ and ignore content of books dir

This commit is contained in:
2026-08-06 17:18:23 +02:00
parent 8d499c28a7
commit 060d822654
5 changed files with 276 additions and 8 deletions
+3 -2
View File
@@ -7,6 +7,7 @@ import (
"path/filepath"
"strings"
"github.com/a-h/templ"
"github.com/arnef/ebooks/internal/library"
"github.com/arnef/ebooks/views"
)
@@ -83,9 +84,9 @@ func (h *Handler) downloadBook(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, cleanPath)
}
func render(w http.ResponseWriter, ctx context.Context, page interface{ Render(context.Context, http.ResponseWriter) error }) {
func render(w http.ResponseWriter, ctx context.Context, c templ.Component) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
if err := page.Render(ctx, w); err != nil && !errors.Is(err, context.Canceled) {
if err := c.Render(ctx, w); err != nil && !errors.Is(err, context.Canceled) {
http.Error(w, "render failed", http.StatusInternalServerError)
}
}