diff --git a/go.mod b/go.mod
index 2c4b244..319ac72 100644
--- a/go.mod
+++ b/go.mod
@@ -4,6 +4,6 @@ go 1.21.5
require (
github.com/a-h/templ v0.2.513
- github.com/go-chi/chi v1.5.5
github.com/go-chi/chi/v5 v5.0.11
+ github.com/mavolin/go-htmx v1.0.0
)
diff --git a/go.sum b/go.sum
index 47f649f..5c1137b 100644
--- a/go.sum
+++ b/go.sum
@@ -1,8 +1,8 @@
github.com/a-h/templ v0.2.513 h1:ZmwGAOx4NYllnHy+FTpusc4+c5msoMpPIYX0Oy3dNqw=
github.com/a-h/templ v0.2.513/go.mod h1:9gZxTLtRzM3gQxO8jr09Na0v8/jfliS97S9W5SScanM=
-github.com/go-chi/chi v1.5.5 h1:vOB/HbEMt9QqBqErz07QehcOKHaWFtuj87tTDVz2qXE=
-github.com/go-chi/chi v1.5.5/go.mod h1:C9JqLr3tIYjDOZpzn+BCuxY8z8vmca43EeMgyZt7irw=
github.com/go-chi/chi/v5 v5.0.11 h1:BnpYbFZ3T3S1WMpD79r7R5ThWX40TaFB7L31Y8xqSwA=
github.com/go-chi/chi/v5 v5.0.11/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
+github.com/mavolin/go-htmx v1.0.0 h1:43rZuemWd23zrMcTU939EsflXjOPxtHy9VraT1CZ6qQ=
+github.com/mavolin/go-htmx v1.0.0/go.mod h1:r6O09gzKou9kutq3UiDPZ//Q7IeBCMcs8US5/sHFbvg=
diff --git a/handler/marketing.go b/handler/marketing.go
index f8ee9ed..9c5b3e1 100644
--- a/handler/marketing.go
+++ b/handler/marketing.go
@@ -3,6 +3,8 @@ package handler
import (
"net/http"
+ "github.com/mavolin/go-htmx"
+
"github.com/tombrereton/go-hot-reload/model"
"github.com/tombrereton/go-hot-reload/view/layout"
"github.com/tombrereton/go-hot-reload/view/marketing"
@@ -14,12 +16,22 @@ type Marketing struct {
func (h *Marketing) GetLandingPage(w http.ResponseWriter, r *http.Request) {
user := model.User{ID: 1, Name: "Bob Loblaw"}
p := marketing.LandingPage(user)
- b := layout.Base(p)
- b.Render(r.Context(), w)
+
+ if htmx.Request(r) != nil {
+ p.Render(r.Context(), w)
+ } else {
+ b := layout.Base(p)
+ b.Render(r.Context(), w)
+ }
}
func (h *Marketing) GetAboutPage(w http.ResponseWriter, r *http.Request) {
p := marketing.AboutPage()
- b := layout.Base(p)
- b.Render(r.Context(), w)
+
+ if htmx.Request(r) != nil {
+ p.Render(r.Context(), w)
+ } else {
+ b := layout.Base(p)
+ b.Render(r.Context(), w)
+ }
}
diff --git a/view/components/header.templ b/view/components/header.templ
index e706962..ca58fc8 100644
--- a/view/components/header.templ
+++ b/view/components/header.templ
@@ -1,5 +1,17 @@
package components
templ Header() {
-
Header
+ Header
+
+
}
diff --git a/view/components/header_templ.go b/view/components/header_templ.go
index fff0e30..20467e5 100644
--- a/view/components/header_templ.go
+++ b/view/components/header_templ.go
@@ -32,7 +32,25 @@ func Header() templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
diff --git a/view/layout/base.templ b/view/layout/base.templ
index fd9555f..04debb2 100644
--- a/view/layout/base.templ
+++ b/view/layout/base.templ
@@ -2,17 +2,19 @@ package layout
import "github.com/tombrereton/go-hot-reload/view/components"
-
templ Base(contents templ.Component) {
My Page
+
- @components.Header()
+ @components.Header()
Layout
- @contents
- @components.Footer()
+
+ @contents
+
+ @components.Footer()
}
diff --git a/view/layout/base_templ.go b/view/layout/base_templ.go
index c2fd94c..9f1d93b 100644
--- a/view/layout/base_templ.go
+++ b/view/layout/base_templ.go
@@ -34,7 +34,16 @@ func Base(contents templ.Component) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -46,12 +55,12 @@ func Base(contents templ.Component) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Var3 := `Layout`
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var3)
+ templ_7745c5c3_Var4 := `Layout`
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var4)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -59,6 +68,10 @@ func Base(contents templ.Component) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
templ_7745c5c3_Err = components.Footer().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err