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>
}
templ navigation(heading string) {
{{ links := []string{"Stuff", "Mindflow", "About", "Guestbook"} }}
templ navigation(title string) {
{{ sections := []string{"Stuff", "Mindflow", "About", "Guestbook"} }}
<nav>
<div>
if heading != "Home" {
if title != "Home" {
<a href="/">Home</a>
}
for _, n := range links {
if n == heading {
for _, s := range sections {
if strings.HasSuffix(title, s) {
{{ continue }}
}
<a href={ templ.URL("/"+strings.ToLower(n)) }>{ n }</a>
<a href={ templ.URL("/"+strings.ToLower(s)) }>{ s }</a>
}
</div>
if heading != "" && heading != "Home" {
if strings.HasSuffix(heading, "Article") {
<h1>Article</h1>
} else {
<h1>{ heading }</h1>
}
if title != "" && title != "Home" {
<h1>
if strings.HasSuffix(title, "- Stuff") {
Stuff
} else {
{ title }
}
</h1>
}
</nav>
}