diff --git a/dev.sh b/dev.sh index 3df34be..1c8f632 100755 --- a/dev.sh +++ b/dev.sh @@ -1,5 +1,5 @@ templ generate --watch --proxy="http://localhost:8080" --cmd="go run ." & -npm run watch & +npm run watch read -n1 -s kill $(jobs -p) diff --git a/handler/render.go b/handler/render.go index 21e062d..969f79a 100644 --- a/handler/render.go +++ b/handler/render.go @@ -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) } diff --git a/handler/index_and_404.go b/handler/root_and_404.go similarity index 79% rename from handler/index_and_404.go rename to handler/root_and_404.go index 82245a4..4d836dd 100644 --- a/handler/index_and_404.go +++ b/handler/root_and_404.go @@ -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 } diff --git a/package.json b/package.json index d400340..8ee90b6 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "description": "Your (almost) independent tech stack to host on a VPC.", "main": "index.js", "scripts": { - "build": "mkdir -p static/js && cp -f node_modules/htmx.org/dist/htmx.min.js static/js/htmx.min.js && tailwindcss -i input.css -o static/css/tailwind.css --minify", - "watch": "mkdir -p static/js && cp -f node_modules/htmx.org/dist/htmx.min.js static/js/htmx.min.js && tailwindcss -i input.css -o static/css/tailwind.css --watch" + "build": "cp -f node_modules/htmx.org/dist/htmx.min.js static/js/htmx.min.js && tailwindcss -i input.css -o static/css/tailwind.css --minify", + "watch": "cp -f node_modules/htmx.org/dist/htmx.min.js static/js/htmx.min.js && tailwindcss -i input.css -o static/css/tailwind.css --watch" }, "keywords": [], "author": "", diff --git a/template/dashboard.templ b/template/dashboard.templ new file mode 100644 index 0000000..700d65d --- /dev/null +++ b/template/dashboard.templ @@ -0,0 +1,9 @@ +package template + +templ Dashboard() { +