htmgo/examples/sse-with-state/pages/root.go

25 lines
525 B
Go
Raw Normal View History

2024-10-08 17:48:28 +00:00
package pages
import (
"github.com/maddalax/htmgo/framework/h"
2024-10-16 20:43:34 +00:00
"github.com/maddalax/htmgo/framework/session"
2024-10-08 17:48:28 +00:00
)
2024-10-09 14:57:51 +00:00
func RootPage(ctx *h.RequestContext, children ...h.Ren) h.Ren {
2024-10-16 20:43:34 +00:00
s := session.NewState(ctx)
2024-10-08 17:48:28 +00:00
return h.Html(
2024-10-15 18:51:26 +00:00
h.Attribute("data-session-id", string(s.SessionId)),
2024-10-08 17:48:28 +00:00
h.HxExtension(h.BaseExtensions()),
h.Head(
h.Link("/public/main.css", "stylesheet"),
h.Script("/public/htmgo.js"),
),
h.Body(
h.Div(
h.Class("flex flex-col gap-2 bg-white h-full"),
h.Fragment(children...),
),
),
)
}