themes-terminal/toc.templ
Alex Dunmow 0a9b177f7c initial: theme plugin terminal
Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously
an unversioned directory inside ~/src/blockninja-themes/terminal.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 14:11:44 +08:00

28 lines
526 B
Plaintext

package main
func tocAnchorHref(anchor string) string {
if anchor == "" {
return "#"
}
return "#" + anchor
}
templ tocComponent(data TocData) {
<nav class="terminal-toc" data-block="terminal:toc">
<h4>{ data.Heading }</h4>
if len(data.Items) > 0 {
<ul>
for _, item := range data.Items {
<li>
<a href={ templ.SafeURL(tocAnchorHref(item.Anchor)) }>
{ "§ " + item.Label }
</a>
</li>
}
</ul>
} else {
<p class="terminal-mono">{ "// no sections yet" }</p>
}
</nav>
}