Support server-rendered index.html for all clients. Closes #1871

This commit is contained in:
Gabe Kangas
2022-06-19 16:35:55 -07:00
parent 78c6189c02
commit ff968616ba
5 changed files with 69 additions and 57 deletions

16
static/static.go vendored
View File

@@ -5,6 +5,8 @@ import (
"html/template"
"os"
"path/filepath"
"github.com/pkg/errors"
)
//go:embed web/*
@@ -18,13 +20,15 @@ func GetWeb() embed.FS {
return webFiles
}
//go:embed metadata.html.tmpl
var botMetadataTemplate embed.FS
// GetWebIndexTemplate will return the bot/scraper metadata template.
func GetWebIndexTemplate() (*template.Template, error) {
webFiles := GetWeb()
name := "web/index.html"
t, err := template.ParseFS(webFiles, name)
if err != nil {
return nil, errors.Wrap(err, "unable to open index.html template")
}
// GetBotMetadataTemplate will return the bot/scraper metadata template.
func GetBotMetadataTemplate() (*template.Template, error) {
name := "metadata.html.tmpl"
t, err := template.ParseFS(botMetadataTemplate, name)
tmpl := template.Must(t, err)
return tmpl, err
}