feat: add custom Datastar.js configuration support

Allow users to provide their own Datastar.js script (e.g., Datastar Pro
or custom builds) via Via's Options configuration. Adds DatastarConfig
struct with Content ([]byte) and Path (string) fields.
This commit is contained in:
Ryan Hamamura
2026-01-14 01:47:39 -10:00
parent 03b6d7453a
commit ea7b9ad4a1
4 changed files with 101 additions and 15 deletions

View File

@@ -2,6 +2,17 @@ package via
import "github.com/alexedwards/scs/v2"
// DatastarConfig configures a custom Datastar.js script.
type DatastarConfig struct {
// Content is the Datastar.js script content.
// If nil, the embedded default is used.
Content []byte
// Path is the URL path where the script is served.
// Defaults to "/_datastar.js" if empty.
Path string
}
type LogLevel int
const (
@@ -37,4 +48,8 @@ type Options struct {
// with scs LoadAndSave middleware. Configure the session manager before
// passing it (lifetime, cookie settings, store, etc).
SessionManager *scs.SessionManager
// Datastar configures a custom Datastar.js script.
// If nil, Via uses its embedded default.
Datastar *DatastarConfig
}