From 518c71203871c3923359c82a9d8678f3ee3c0d7e Mon Sep 17 00:00:00 2001 From: "Gustavo L de Mello (Guz)" Date: Fri, 11 Oct 2024 14:13:34 -0300 Subject: [PATCH] fix(dev): hot reloading --- package.json | 1 + pages/dashboard.templ | 12 ++++++++---- router/rerrors/errors.go | 4 ++-- templates/layouts/page.templ | 10 ++++++++++ 4 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 templates/layouts/page.templ diff --git a/package.json b/package.json index 6499461..e109f4d 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,5 @@ { + "type": "module", "devDependencies": { "eslint": "^9.12.0", "unocss": "^0.63.3" diff --git a/pages/dashboard.templ b/pages/dashboard.templ index ffffc8c..abc8499 100644 --- a/pages/dashboard.templ +++ b/pages/dashboard.templ @@ -4,6 +4,7 @@ import ( "net/http" "forge.capytal.company/capytalcode/project-comicverse/router/rerrors" + "forge.capytal.company/capytalcode/project-comicverse/templates/layouts" ) type Dashboard struct{} @@ -13,11 +14,14 @@ func (p *Dashboard) ServeHTTP(w http.ResponseWriter, r *http.Request) { rerrors.InternalError(err).ServeHTTP(w, r) return } - w.WriteHeader(http.StatusOK) } templ (p *Dashboard) Component() { -
-

Hello world

-
+ @layouts.Page() { +
+

Hello world

+

test

+

test

+
+ } } diff --git a/router/rerrors/errors.go b/router/rerrors/errors.go index 9a2d4c3..435f58c 100644 --- a/router/rerrors/errors.go +++ b/router/rerrors/errors.go @@ -47,11 +47,11 @@ func (rerr RouteError) ServeHTTP(w http.ResponseWriter, r *http.Request) { "error": err.Error(), }, }) - w.Write(j) w.WriteHeader(http.StatusInternalServerError) + w.Write(j) return } - w.Write(j) w.WriteHeader(rerr.StatusCode) + w.Write(j) } diff --git a/templates/layouts/page.templ b/templates/layouts/page.templ new file mode 100644 index 0000000..a4a4bc4 --- /dev/null +++ b/templates/layouts/page.templ @@ -0,0 +1,10 @@ +package layouts + +templ Page() { + + + + { children... } + + +}