aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2025-10-02 18:53:56 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2025-10-02 18:53:56 +0200
commitf6c7a85ca04b9285677227d66205856c31a7d364 (patch)
treea343eacc23b8cbd7013fcf7318258ad657962867
parentcc2f31d6d5f47472e7162c9aec605587f0abaad8 (diff)
feat(backend): config header links
-rw-r--r--backend/config.go16
-rw-r--r--backend/data.go4
-rw-r--r--backend/templates/base.html9
-rw-r--r--backend/templates/home.html2
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 @@
<header>
<img src="https://cdn.anhgelus.world/pfp.jpg" alt="pfp">
<nav>
- <a href="">Home</a>
- <a href="">Logs</a>
- <a href="">Work</a>
- <a href="">Philosophy</a>
- <a href="">Lien 1</a>
- <a href="">Lien 2</a>
- <a href="">Lien 3</a>
- <a href="">Lien 4</a>
+ {{ range .Links }}<a href="{{ .URL }}">{{ .Name }}</a>{{end}}
</nav>
</header>
{{ 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 @@
<div class="introduction">
<h1>logs</h1>
<p>
- 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 }}
</p>
</div>
<article>