package html
import (
"embed"
"html/template"
"io"
"time"
)
func rawHtml(str string) template.HTML {
return template.HTML(str)
}
func tsToDate(t int) string {
tm := time.Unix(int64(t), 0).UTC()
return tm.Format(time.DateTime)
}
var funcs = template.FuncMap{
"raw": rawHtml,
"tsToDate": tsToDate,
}
//go:embed intake.css
var Stylesheet []byte
//go:embed *.html
var templates embed.FS
func load(file string) *template.Template {
return template.Must(template.New("layout.html").Funcs(funcs).ParseFS(templates, "layout.html", file))
}
var home = load("home.html")
func Home(writer io.Writer, data any) error {
return home.Execute(writer, data)
}
var feed = load("feed.html")
func Feed(writer io.Writer, data any) error {
return feed.Execute(writer, data)
}