mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-04 10:21:40 +00:00
feat: implement hero section using Pkl
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user