1
0

Updated templ navigation().

This commit is contained in:
Alexander Andreev 2024-06-21 00:52:06 +04:00
parent b1d7f92cff
commit 5fedded1de
Signed by: Arav
GPG Key ID: 25969B23DCB5CA34

View File

@ -45,26 +45,28 @@ templ base(title, description, keywords, canonical string, head templ.Component)
</html> </html>
} }
templ navigation(heading string) { templ navigation(title string) {
{{ links := []string{"Stuff", "Mindflow", "About", "Guestbook"} }} {{ sections := []string{"Stuff", "Mindflow", "About", "Guestbook"} }}
<nav> <nav>
<div> <div>
if heading != "Home" { if title != "Home" {
<a href="/">Home</a> <a href="/">Home</a>
} }
for _, n := range links { for _, s := range sections {
if n == heading { if strings.HasSuffix(title, s) {
{{ continue }} {{ continue }}
} }
<a href={ templ.URL("/"+strings.ToLower(n)) }>{ n }</a> <a href={ templ.URL("/"+strings.ToLower(s)) }>{ s }</a>
} }
</div> </div>
if heading != "" && heading != "Home" { if title != "" && title != "Home" {
if strings.HasSuffix(heading, "Article") { <h1>
<h1>Article</h1> if strings.HasSuffix(title, "- Stuff") {
Stuff
} else { } else {
<h1>{ heading }</h1> { title }
} }
</h1>
} }
</nav> </nav>
} }