From f6c7a85ca04b9285677227d66205856c31a7d364 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Thu, 2 Oct 2025 18:53:56 +0200 Subject: feat(backend): config header links --- backend/config.go | 16 ++++++++++++++++ backend/data.go | 4 ++++ backend/templates/base.html | 9 +-------- backend/templates/home.html | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/backend/config.go b/backend/config.go index 15cc585..5e6620b 100644 --- a/backend/config.go +++ b/backend/config.go @@ -8,16 +8,32 @@ import ( "github.com/pelletier/go-toml/v2" ) +type Link struct { + Name string `toml:"name"` + URL string `toml:"url"` +} + type Config struct { Domain string `toml:"domain"` Name string `toml:"name"` Description string `toml:"description"` + Links []Link `toml:"links"` } func (c *Config) DefaultValues() { c.Domain = "example.org" c.Name = "example" c.Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim aeque doleamus animo, cum corpore dolemus, fieri tamen permagna accessio potest, si aliquod aeternum et infinitum impendere malum nobis opinemur. Quod idem licet transferre in voluptatem, ut." + c.Links = []Link{ + { + Name: "Home", + URL: "/", + }, + { + Name: "Logs", + URL: "/log/", + }, + } } func LoadConfig(path string) (*Config, bool) { diff --git a/backend/data.go b/backend/data.go index fd05fa9..85e8681 100644 --- a/backend/data.go +++ b/backend/data.go @@ -15,6 +15,7 @@ type data struct { Image string Description string Name string + Links []Link } func (d *data) handleGeneric(w http.ResponseWriter, r *http.Request, name string) { @@ -28,6 +29,9 @@ func (d *data) handleGeneric(w http.ResponseWriter, r *http.Request, name string if d.Description == "" { d.Description = cfg.Description } + if d.Links == nil { + d.Links = cfg.Links + } if d.URL == "" { if !strings.HasPrefix(r.URL.Path, "/") { r.URL.Path = "/" + r.URL.Path diff --git a/backend/templates/base.html b/backend/templates/base.html index 1a7093d..ec3f25a 100644 --- a/backend/templates/base.html +++ b/backend/templates/base.html @@ -26,14 +26,7 @@
pfp
{{ if .Article }} diff --git a/backend/templates/home.html b/backend/templates/home.html index ed450ac..fb927eb 100644 --- a/backend/templates/home.html +++ b/backend/templates/home.html @@ -2,7 +2,7 @@

logs

- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim aeque doleamus animo, cum corpore dolemus, fieri tamen permagna accessio potest, si aliquod aeternum et infinitum impendere. + {{ .Description }}

-- cgit v1.2.3