dispatch/server/index.egon.go
2018-11-09 07:12:43 +01:00

37 lines
1.8 KiB
Go

// Generated by egon.
// 🚫Edit at your own risk.
package server
import (
"io"
"github.com/mailru/easyjson"
)
func IndexTemplate(w io.Writer, data *indexData, cssPath string, inlineScript string, scripts []string, sw bool) error {
io.WriteString(w, "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><meta name=\"theme-color\" content=\"#f0f0f0\"><title>Dispatch</title>")
if sw {
io.WriteString(w, "<link rel=\"preload\" href=\"/data\" as=\"fetch\" crossorigin=\"anonymous\">")
}
io.WriteString(w, "<script>")
io.WriteString(w, inlineScript )
io.WriteString(w, "</script><link rel=\"preload\" href=\"/font/fontello.woff2?48901973\" as=\"font\" type=\"font/woff2\" crossorigin=\"anonymous\"><link rel=\"preload\" href=\"/font/RobotoMono-Regular.woff2\" as=\"font\" type=\"font/woff2\" crossorigin=\"anonymous\"><link rel=\"preload\" href=\"/font/Montserrat-Regular.woff2\" as=\"font\" type=\"font/woff2\" crossorigin=\"anonymous\"><link rel=\"preload\" href=\"/font/Montserrat-Bold.woff2\" as=\"font\" type=\"font/woff2\" crossorigin=\"anonymous\"><link rel=\"preload\" href=\"/font/RobotoMono-Bold.woff2\" as=\"font\" type=\"font/woff2\" crossorigin=\"anonymous\">")
if cssPath != "" {
io.WriteString(w, "<link href=\"")
io.WriteString(w, cssPath )
io.WriteString(w, "\" rel=\"stylesheet\">")
}
io.WriteString(w, "<link rel=\"icon\" href=\"data:;base64,=\"></head><body><div id=\"root\"></div>")
if data != nil {
io.WriteString(w, "<script id=\"env\" type=\"application/json\">")
easyjson.MarshalToWriter(data, w)
io.WriteString(w, "</script>")
}
for _, script := range scripts {
io.WriteString(w, "<script src=\"")
io.WriteString(w, script )
io.WriteString(w, "\"></script>")
}
io.WriteString(w, "</body></html>")
return nil
}