feat(layout): #49 update layout by navigation
This commit was merged in pull request #57.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user