fix(gallery): use component template
release.yaml / publish (push) Successful in 3m51s

This commit is contained in:
schreifuchs committed 2026-09-29 10:46:45 +02:00
1 parent 297efaa4a6
commit 812891a205
7 files changed
+36 -15

No files matched your search

+8 -2
View File
@@ -23,7 +23,6 @@ templ head(cfg config.Cfg, title string) {
@templ.Raw(h)
}
</head>
{ children... }
}
templ Base(cfg config.Cfg, title string) {
@@ -38,13 +37,20 @@ templ Base(cfg config.Cfg, title string) {
</html>
}
templ Content(cfg config.Cfg, title string) {
templ Page(cfg config.Cfg, title string) {
@head(cfg, title)
@body() {
{ children... }
}
}
templ Component() {
for _, h := range templer.GetHeader(ctx) {
@templ.Raw(h)
}
{ children... }
}
templ body() {
<header
class="fixed z-50 mix-blend-difference p-1 w-full flex justify-between items-start"
+13 -7
View File
@@ -2,7 +2,6 @@ package layouts
import (
"context"
"fmt"
"io"
"log/slog"
"net/http"
@@ -22,12 +21,9 @@ func New(cfg config.Cfg) *Layouts {
}
}
// Render renders a page. If the query paramenter "c" is set
// RenderPage renders a page. If the query paramenter HX-Request is set
// the component gets rendered without the layout
func (l *Layouts) Render(ctx context.Context, w io.Writer, r *http.Request, component templ.Component) {
withLayout := !r.URL.Query().Has("c")
fmt.Println("layout: ", withLayout)
func (l *Layouts) RenderPage(ctx context.Context, w io.Writer, r *http.Request, component templ.Component) {
title := templer.GetTitle(ctx, "Schreifuchs")
slog.Debug("HX-Request", "value", r.Header.Get("HX-Request"))
@@ -36,10 +32,20 @@ func (l *Layouts) Render(ctx context.Context, w io.Writer, r *http.Request, comp
component = Base(l.cfg, title)
} else {
ctx = templ.WithChildren(ctx, component)
component = Content(l.cfg, title)
component = Page(l.cfg, title)
}
if err := component.Render(ctx, w); err != nil {
slog.Error("error while rendering component", "err", err, "ctx", ctx)
}
}
// RenderComponent renders a component alone.
func (l *Layouts) RenderComponent(ctx context.Context, w io.Writer, r *http.Request, component templ.Component) {
ctx = templ.WithChildren(ctx, component)
component = Component()
if err := component.Render(ctx, w); err != nil {
slog.Error("error while rendering component", "err", err, "ctx", ctx)
}
}