Place navigation inside a base template.
This commit is contained in:
parent
c5418710e5
commit
46e5213b36
@ -33,7 +33,30 @@ templ base(title, description, keywords, canonical string, head templ.Component)
|
||||
<text y="7" textLength="360" lengthAdjust="spacingAndGlyphs">Arav's dwelling</text>
|
||||
<text y="25" textLength="360" lengthAdjust="spacingAndGlyphs">Welcome to my sacred place, wanderer</text>
|
||||
</svg>
|
||||
@navigation(title)
|
||||
{{ mainNavSections := []string{"Stuff", "Mindflow", "About", "Guestbook"} }}
|
||||
{{ mainNavLinks := []templ.SafeURL{"/stuff", "/mindflow", "/about", "/guestbook"} }}
|
||||
<nav>
|
||||
<ul>
|
||||
if title != "" {
|
||||
<li><a href="/">Home</a></li>
|
||||
}
|
||||
for i, s := range mainNavSections {
|
||||
if strings.HasSuffix(title, s) {
|
||||
{{ continue }}
|
||||
}
|
||||
<li><a href={ mainNavLinks[i] }>{ s }</a></li>
|
||||
}
|
||||
</ul>
|
||||
if title != "" {
|
||||
<h1>
|
||||
if strings.HasSuffix(title, "- Stuff") {
|
||||
Stuff
|
||||
} else {
|
||||
{ title }
|
||||
}
|
||||
</h1>
|
||||
}
|
||||
</nav>
|
||||
</header>
|
||||
<main>
|
||||
{ children... }
|
||||
@ -45,31 +68,4 @@ templ base(title, description, keywords, canonical string, head templ.Component)
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
|
||||
templ navigation(title string) {
|
||||
{{ sections := []string{"Stuff", "Mindflow", "About", "Guestbook"} }}
|
||||
{{ links := []templ.SafeURL{"/stuff", "/mindflow", "/about", "/guestbook"} }}
|
||||
<nav>
|
||||
<ul>
|
||||
if title != "" {
|
||||
<li><a href="/">Home</a></li>
|
||||
}
|
||||
for i, s := range sections {
|
||||
if strings.HasSuffix(title, s) {
|
||||
{{ continue }}
|
||||
}
|
||||
<li><a href={ links[i] }>{ s }</a></li>
|
||||
}
|
||||
</ul>
|
||||
if title != "" {
|
||||
<h1>
|
||||
if strings.HasSuffix(title, "- Stuff") {
|
||||
Stuff
|
||||
} else {
|
||||
{ title }
|
||||
}
|
||||
</h1>
|
||||
}
|
||||
</nav>
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user