feat: implement hero section using Pkl

This commit is contained in:
Prad Nukala
2024-09-30 21:16:13 -04:00
parent 3e9139bd58
commit 5f2e6c5dd4
14 changed files with 189 additions and 107 deletions
+8 -6
View File
@@ -1,18 +1,21 @@
package nebula
import (
"context"
"embed"
"io/fs"
"net/http"
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/models"
)
//go:embed assets
var embeddedFiles embed.FS
//go:embed assets/config.pkl
var config []byte
var config string
func getHTTPFS() (http.FileSystem, error) {
fsys, err := fs.Sub(embeddedFiles, "assets")
@@ -24,6 +27,10 @@ func getHTTPFS() (http.FileSystem, error) {
// UseAssets is a middleware that serves static files from the embedded assets
func UseAssets(e *echo.Echo) error {
err := models.LoadFromString(context.Background(), config)
if err != nil {
return err
}
fsys, err := getHTTPFS()
if err != nil {
return err
@@ -33,8 +40,3 @@ func UseAssets(e *echo.Echo) error {
e.GET("/assets/*", echo.WrapHandler(http.StripPrefix("/assets/", assets)))
return nil
}
// GetConfig is a middleware that serves the config file
func GetConfig(e echo.Context) error {
return e.Blob(http.StatusOK, "application/octet-stream", config)
}