Update. Add svelte admin frontend
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user