From 1e8c6648072ea2cd997a2decd1c4a1c902d620b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Wed, 24 Jan 2024 00:31:37 -0800 Subject: [PATCH] load home template from the cache properly --- internal/handlers/handlers.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 9c7e12c..06fe912 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -45,7 +45,19 @@ func Initialise(a *config.AppConfig) { // HomeHandler handles /, generating data from Handlers func HomeHandler(w http.ResponseWriter, r *http.Request) { app.Logger.Info("Got request for homepage") - d := td.MakeBasicTemplateData(time.Now()) + + page := "home.page.tmpl" + d := models.TemplateData{} + + t, err := render.GetTemplateFromCache(page) + if err != nil { + app.Logger.Error(fmt.Sprintf("couldn't get %s from cache", page), "err", err) + } else { + d.StringMap = map[string]string{ + "GeneratedAt": t.GeneratedAt.Format(time.UnixDate), + } + } + var pages []models.Link = []models.Link{} for _, handler := range Handlers {