Routes are struct fields
Nest structs to nest routes; route tags hold the path and title. Mount builds the tree onto any http.ServeMux, with no registration calls.
Beta — battle-tested in production
Built on http.ServeMux. gsx and HTMX first. Type-safe URLs.
type index struct {
product `route:"/product Product"`
team `route:"/team Team"`
}
type product struct{}
type team struct{}
component (p index) Page() {
<html>
<body>
<h1>Welcome</h1>
<a href={product{} |> url}>Product</a>
<a href={team{} |> url}>Team</a>
</body>
</html>
}
component (p product) Page() {
<h1>Product</h1>
}
component (p team) Page() {
<h1>Team</h1>
}func main() {
mux := http.NewServeMux()
if _, err := structpages.Mount(mux, index{}, "/", "Home"); err != nil {
log.Fatal(err)
}
log.Fatal(http.ListenAndServe(":8080", mux))
}/plugin marketplace add jackielii/structpages