feat(layout): #49 update layout by navigation
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 5m0s
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 5m0s

This commit was merged in pull request #57.
This commit is contained in:
2025-05-06 22:10:49 +02:00
parent 605c64ef92
commit b8f13dfc93
6 changed files with 80 additions and 51 deletions

View File

@@ -38,7 +38,7 @@ func (render *Render) RenderLayout(r *http.Request, w http.ResponseWriter, slot
func (render *Render) RenderLayoutWithStatus(r *http.Request, w http.ResponseWriter, slot templ.Component, user *types.User, status int) {
userComp := render.getUserComp(user)
layout := template.Layout(slot, userComp)
layout := template.Layout(slot, userComp, user != nil, r.URL.Path)
render.RenderWithStatus(r, w, layout, status)
}

View File

@@ -27,10 +27,10 @@ func NewIndex(service service.Auth, render *Render) Index {
}
func (handler IndexImpl) Handle(router *http.ServeMux) {
router.Handle("/", handler.handleIndexAnd404())
router.Handle("/", handler.handleRootAnd404())
}
func (handler IndexImpl) handleIndexAnd404() http.HandlerFunc {
func (handler IndexImpl) handleRootAnd404() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
user := middleware.GetUser(r)
@@ -41,7 +41,11 @@ func (handler IndexImpl) handleIndexAnd404() http.HandlerFunc {
comp = template.NotFound()
status = http.StatusNotFound
} else {
comp = template.Index()
if user != nil {
comp = template.Dashboard()
} else {
comp = template.Index()
}
status = http.StatusOK
}