From 0de89e6bc6a467b2cc4261ae65464f40119cc0ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Herg=C3=A8s?= Date: Fri, 3 Oct 2025 18:40:45 +0200 Subject: feat(frontend): use htmx to dynamically navigate between pages --- backend/data.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'backend/data.go') diff --git a/backend/data.go b/backend/data.go index 8922aca..cc61941 100644 --- a/backend/data.go +++ b/backend/data.go @@ -31,7 +31,7 @@ type data struct { } func (d *data) handleGeneric(w http.ResponseWriter, r *http.Request, name string, custom dataUsable) { - cfg := r.Context().Value("config").(*Config) + cfg := r.Context().Value(configKey).(*Config) if d.Domain == "" { d.Domain = cfg.Domain } @@ -75,15 +75,20 @@ func (d *data) handleGeneric(w http.ResponseWriter, r *http.Request, name string }, "next": func(i int) int { return i + 1 }, "before": func(i int) int { return i - 1 }, - }).ParseFS(templates, "templates/logs_display.html", fmt.Sprintf("templates/%s.html", name), "templates/base.html") + }).ParseFS(templates, "templates/components.html", fmt.Sprintf("templates/%s.html", name), "templates/base.html") if err != nil { panic(err) } + exec := "base.html" + if r.Context().Value(isUpdateKey).(bool) { + exec = "body" + w.Header().Set("Updated-Title", d.Title()) + } if custom == nil { - err = t.ExecuteTemplate(w, "base.html", d) + err = t.ExecuteTemplate(w, exec, d) } else { custom.SetData(d) - err = t.ExecuteTemplate(w, "base.html", custom) + err = t.ExecuteTemplate(w, exec, custom) } if err != nil { panic(err) -- cgit v1.2.3