mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-04 18:31:41 +00:00
feat: implement hero section using Pkl
This commit is contained in:
@@ -1 +1,36 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/apple/pkl-go/pkl"
|
||||
)
|
||||
|
||||
var models *Models
|
||||
|
||||
func LoadFromString(ctx context.Context, s string) (err error) {
|
||||
evaluator, err := pkl.NewEvaluator(ctx, pkl.PreconfiguredOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
cerr := evaluator.Close()
|
||||
if err == nil {
|
||||
err = cerr
|
||||
}
|
||||
}()
|
||||
ret, err := Load(ctx, evaluator, pkl.TextSource(s))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
models = ret
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetModels() (*Models, error) {
|
||||
if models == nil {
|
||||
return nil, errors.New("models not initialized")
|
||||
}
|
||||
return models, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user