diff options
Diffstat (limited to 'pkg/handler')
-rw-r--r-- | pkg/handler/random.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/pkg/handler/random.go b/pkg/handler/random.go index 091058f..29c5f6f 100644 --- a/pkg/handler/random.go +++ b/pkg/handler/random.go @@ -1,6 +1,7 @@ package handler import ( + "github.com/a-h/templ" "github.com/labstack/echo/v4" "sh.org.ru/pkg/model" "sh.org.ru/pkg/tpl" @@ -14,5 +15,17 @@ func (h *Handler) Random(c echo.Context) error { return err } - return tpl.Random(quotes).Render(c.Request().Context(), c.Response()) + comp := tpl.Random(quotes) + + if c.Request().Header.Get("Hx-Request") == "true" { + return comp.Render(c.Request().Context(), c.Response()) + } + + ctx := templ.WithChildren(c.Request().Context(), comp) + + return tpl.Layout(tpl.HeaderParams{ + Title: "Цитатник Рунета", + Description: "Новый цитатник Рунета", + URL: "https://sh.org.ru/", + }).Render(ctx, c.Response()) } |