2016-03-16 22:23:16 +00:00
|
|
|
// Generated by egon.
|
|
|
|
// 🚫Edit at your own risk.
|
|
|
|
|
|
|
|
package server
|
|
|
|
import (
|
|
|
|
"io"
|
2018-05-25 21:54:36 +00:00
|
|
|
"github.com/mailru/easyjson"
|
2016-03-16 22:23:16 +00:00
|
|
|
)
|
|
|
|
|
2018-11-09 05:30:31 +00:00
|
|
|
func IndexTemplate(w io.Writer, data *indexData, cssPath string, inlineScript string, scripts []string, sw bool) error {
|
2018-11-10 11:18:45 +00:00
|
|
|
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>")
|
2018-11-09 05:30:31 +00:00
|
|
|
if sw {
|
2018-11-10 11:18:45 +00:00
|
|
|
io.WriteString(w, "<link rel=\"preload\" href=\"/data\" as=\"fetch\" crossorigin=\"anonymous\" />")
|
2018-11-09 05:30:31 +00:00
|
|
|
}
|
|
|
|
io.WriteString(w, "<script>")
|
|
|
|
io.WriteString(w, inlineScript )
|
2018-11-10 11:18:45 +00:00
|
|
|
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\" />")
|
2018-11-04 06:22:46 +00:00
|
|
|
if cssPath != "" {
|
2018-11-07 00:35:53 +00:00
|
|
|
io.WriteString(w, "<link href=\"")
|
2016-03-16 22:23:16 +00:00
|
|
|
io.WriteString(w, cssPath )
|
2018-11-10 11:18:45 +00:00
|
|
|
io.WriteString(w, "\" rel=\"stylesheet\" />")
|
2018-11-04 06:22:46 +00:00
|
|
|
}
|
2018-11-10 11:18:45 +00:00
|
|
|
io.WriteString(w, "<link rel=\"manifest\" href=\"/manifest.json\"></head><body><div id=\"root\"></div>")
|
2018-11-06 10:13:32 +00:00
|
|
|
if data != nil {
|
|
|
|
io.WriteString(w, "<script id=\"env\" type=\"application/json\">")
|
2018-05-25 21:54:36 +00:00
|
|
|
easyjson.MarshalToWriter(data, w)
|
2018-11-04 06:22:46 +00:00
|
|
|
io.WriteString(w, "</script>")
|
2018-11-06 10:13:32 +00:00
|
|
|
}
|
2018-11-04 06:22:46 +00:00
|
|
|
for _, script := range scripts {
|
2018-11-07 00:35:53 +00:00
|
|
|
io.WriteString(w, "<script src=\"")
|
2018-11-04 06:22:46 +00:00
|
|
|
io.WriteString(w, script )
|
|
|
|
io.WriteString(w, "\"></script>")
|
|
|
|
}
|
|
|
|
io.WriteString(w, "</body></html>")
|
2016-03-16 22:23:16 +00:00
|
|
|
return nil
|
|
|
|
}
|