reload themefs after change theme in config

This commit is contained in:
Help-14 2022-04-16 21:33:27 +07:00
parent a4cbd26044
commit 0347de57d9

View file

@ -21,6 +21,7 @@ var websiteData = struct {
Contents []modules.GroupData
}{}
var webTemplate *template.Template
var themefs http.Handler
func main() {
prepare()
@ -33,7 +34,6 @@ func main() {
languagefs := http.FileServer(http.Dir(filepath.Join(pwd, "languages")))
http.Handle("/languages/", http.StripPrefix("/languages/", languagefs))
themefs := http.FileServer(http.Dir(filepath.Join(pwd, "themes", appConfig.Website.Theme)))
http.Handle("/theme/", http.StripPrefix("/theme/", themefs))
http.HandleFunc("/weather", serveWeather)
@ -63,6 +63,7 @@ func loadData() {
websiteData.Language = modules.LoadLanguage(appConfig.Website.Language)
websiteData.Contents = modules.LoadContent().Data
themefs = http.FileServer(http.Dir(filepath.Join(pwd, "themes", appConfig.Website.Theme)))
tmpl, _ := template.ParseFiles(filepath.Join(pwd, "themes", appConfig.Website.Theme, "index.html"))
webTemplate = tmpl
}