main.go
package main
import (
"embed"
"github.com/readysite/readysite/example/controllers"
"github.com/readysite/readysite/example/models"
"github.com/readysite/readysite/pkg/application"
"github.com/readysite/readysite/pkg/frontend"
"github.com/readysite/readysite/pkg/frontend/esbuild"
)
//go:embed views
var views embed.FS
func main() {
application.Serve(views,
application.WithValue("theme", "dark"),
frontend.WithBundler(&esbuild.Config{
Entry: "index.ts",
Include: []string{"components"},
}),
application.WithController(controllers.Home()),
)
}
// Seed creates sample posts if none exist.
func init() {
count := models.Posts.Count("")
if count > 0 {
return
}
models.Posts.Insert(&models.Post{
Title: "Welcome to ReadySite",
Content: "This is your first post. Edit or delete it to get started.",
})
models.Posts.Insert(&models.Post{
Title: "Getting Started",
Content: "ReadySite makes it easy to build and deploy websites.",
})
models.Posts.Insert(&models.Post{
Title: "HTMX + DaisyUI",
Content: "Server-rendered HTML with beautiful components.",
})
}