Add auth, rest api, svelte frontend, build structure
This commit is contained in:
@@ -2,7 +2,27 @@ package web
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"net/http"
|
||||
"text/template"
|
||||
|
||||
"github.com/olivere/vite"
|
||||
)
|
||||
|
||||
type PageData struct {
|
||||
Title string
|
||||
MsgType string
|
||||
Message string
|
||||
Redirect string
|
||||
Vite *vite.Fragment
|
||||
}
|
||||
|
||||
//go:embed templates
|
||||
var Templates embed.FS
|
||||
|
||||
//go:embed frontend/dist
|
||||
var StaticAssets embed.FS
|
||||
|
||||
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