Place navigation inside a base template.
This commit is contained in:
parent
c5418710e5
commit
46e5213b36
@ -33,33 +33,18 @@ 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)
|
||||
</header>
|
||||
<main>
|
||||
{ children... }
|
||||
</main>
|
||||
<footer>
|
||||
<a href="/rss.xml" title="Stay up to date on what's going on.">RSS feed</a>
|
||||
<br/>
|
||||
© 2017—2024 Alexander "Arav" Andreev <<a href="mailto:me@arav.su">me@arav.su</a>> <a href="/privacy">Privacy statements</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
|
||||
templ navigation(title string) {
|
||||
{{ sections := []string{"Stuff", "Mindflow", "About", "Guestbook"} }}
|
||||
{{ links := []templ.SafeURL{"/stuff", "/mindflow", "/about", "/guestbook"} }}
|
||||
{{ 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 sections {
|
||||
for i, s := range mainNavSections {
|
||||
if strings.HasSuffix(title, s) {
|
||||
{{ continue }}
|
||||
}
|
||||
<li><a href={ links[i] }>{ s }</a></li>
|
||||
<li><a href={ mainNavLinks[i] }>{ s }</a></li>
|
||||
}
|
||||
</ul>
|
||||
if title != "" {
|
||||
@ -72,4 +57,15 @@ templ navigation(title string) {
|
||||
</h1>
|
||||
}
|
||||
</nav>
|
||||
</header>
|
||||
<main>
|
||||
{ children... }
|
||||
</main>
|
||||
<footer>
|
||||
<a href="/rss.xml" title="Stay up to date on what's going on.">RSS feed</a>
|
||||
<br/>
|
||||
© 2017—2024 Alexander "Arav" Andreev <<a href="mailto:me@arav.su">me@arav.su</a>> <a href="/privacy">Privacy statements</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
}
|
Loading…
Reference in New Issue
Block a user