diff --git a/public/public.go b/public/public.go index c6350f4..209882c 100644 --- a/public/public.go +++ b/public/public.go @@ -4,6 +4,7 @@ import ( "embed" "errors" "fmt" + "html" "io" "io/fs" "log" @@ -47,13 +48,22 @@ func initIndex() { RawIndexFile = string(index) } func UpdateIndex(cfg models.Config) { + var titleReplacement string + if cfg.Sitename == "Komari" { + titleReplacement = "Komari Monitor" + } else { + titleReplacement = fmt.Sprintf("%s - Komari Monitor", html.EscapeString(cfg.Sitename)) + } + replaceMap := map[string]string{ - "": cfg.CustomHead + "", - "": cfg.CustomBody + "", + "Komari Monitor": titleReplacement, + "A simple server monitor tool.": cfg.Description, + "": cfg.CustomHead + "", + "": cfg.CustomBody + "", } updated := RawIndexFile for k, v := range replaceMap { - updated = strings.Replace(updated, k, v, 1) + updated = strings.Replace(updated, k, v, -1) } IndexFile = updated }