Update. Add svelte admin frontend

This commit is contained in:
2025-06-12 20:38:12 +02:00
parent 17ab7c4929
commit 562186fa47
16 changed files with 463 additions and 165 deletions

View File

@@ -2,6 +2,8 @@ package web
import (
"embed"
"fmt"
"io/fs"
"net/http"
"text/template"
@@ -19,9 +21,17 @@ type PageData struct {
//go:embed templates
var Templates embed.FS
//go:embed frontend/dist
//go:embed all:frontend/dist
var StaticAssets embed.FS
func DistFS() fs.FS {
efs, err := fs.Sub(StaticAssets, "frontend/dist")
if err != nil {
panic(fmt.Sprintf("unable to serve frontend: %v", err))
}
return efs
}
func RenderTemplate(w http.ResponseWriter, name string, data PageData) error {
tpl := template.Must(template.ParseFS(Templates, "templates/"+name+".html", "templates/base.html"))
return tpl.ExecuteTemplate(w, "base", data)