From b86e31b92713e9ac752b080bec4b8b350bf17b7c Mon Sep 17 00:00:00 2001 From: Phil Porada Date: Fri, 22 May 2026 13:07:01 -0700 Subject: [PATCH] Allow changing the HTML page title via config --- cmd/sunlight/home.html | 2 +- cmd/sunlight/sunlight.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/sunlight/home.html b/cmd/sunlight/home.html index 43e7f38..e531f91 100644 --- a/cmd/sunlight/home.html +++ b/cmd/sunlight/home.html @@ -5,7 +5,7 @@ - Sunlight + {{ .Title }} diff --git a/cmd/sunlight/sunlight.go b/cmd/sunlight/sunlight.go index 4c903c9..42bc8ef 100644 --- a/cmd/sunlight/sunlight.go +++ b/cmd/sunlight/sunlight.go @@ -65,6 +65,10 @@ import ( ) type Config struct { + // Name is the display name for this Sunlight instance, used as the + // HTML page title. Optional. If empty, the title defaults to "Sunlight". + Name string + // Listen are the addresses to listen on, e.g. ":443". Listen []string @@ -466,10 +470,16 @@ func main() { homeWitnessInfo := func() witnessInfo { return witnessInfo{} } mux.HandleFunc("/{$}", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html") + pageTitle := "Sunlight" + if c.Name != "" { + pageTitle = c.Name + } if err := homeTmpl.Execute(w, struct { + Title string Logs []logInfo Witness witnessInfo }{ + Title: pageTitle, Logs: homeLogsInfo(), Witness: homeWitnessInfo(), }); err != nil {