cerrado @ c7a8aa113a914e70e027fea93265c7232b865b5e

 1{% code
 2type Selection int
 3const (
 4    Git Selection = iota
 5    List
 6    About
 7    Config
 8)
 9%}
10
11{% code
12type GitSelection int
13const (
14    Readme GitSelection = iota
15    Log
16    Summary
17    Refs
18    Tree
19)
20%}
21
22{% func insertIfEqual(s, d any) %}{% if s == d %} selected{% endif %}{% endfunc %}
23
24{% func Navbar (s Selection) %}
25        <nav class="container navbar navbar-expand">
26          <div class="navbar-nav">
27            <a class="nav-link{%= insertIfEqual(s, Git) %}" href="/">git</a>
28{% comment %}
29Add this back once needed
30            <a class="nav-link{%= insertIfEqual(s, List) %}" href="/list">list</a>
31{% endcomment %}
32            <a class="nav-link{%= insertIfEqual(s, About) %}" href="/about">about</a>
33            <a class="nav-link{%= insertIfEqual(s, Config) %}" href="/config">config</a>
34          </div>
35        </nav>
36{% endfunc %}
37
38{% func GitItemNav (name, ref string, s GitSelection) %}
39<div class="row">
40    <h3>{%s name %} {% if ref != "" && (s == Log || s == Tree)  %}@ {%s ref %}{% endif %}</h3>
41</div>
42<div class="row">
43  <ul class="nav">
44    <li class="nav-item">
45      <a class="nav-link{%= insertIfEqual(s, Readme) %}" aria-current="page" href="/{%s name %}/about">about</a>
46    </li>
47    <li class="nav-item">
48      <a class="nav-link{%= insertIfEqual(s, Log) %}" aria-current="page" href="/{%s name %}/log/{%s ref %}">log</a>
49    </li>
50    <li class="nav-item">
51      <a class="nav-link{%= insertIfEqual(s, Summary) %}" aria-current="page" href="/{%s name %}">summary</a>
52    </li>
53    <li class="nav-item">
54      <a class="nav-link{%= insertIfEqual(s, Refs) %}" aria-current="page" href="/{%s name %}/refs">refs</a>
55    </li>
56    <li class="nav-item">
57      <a class="nav-link{%= insertIfEqual(s, Tree) %}" aria-current="page" href="/{%s name %}/tree/{%s ref %}">tree</a>
58    </li>
59  </ul>
60</div>
61{% endfunc %}