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{% comment %}
33Add this back if needed
34 <a class="nav-link{%= insertIfEqual(s, About) %}" href="/about/">about</a>
35{% endcomment %}
36 </div>
37 </nav>
38{% endfunc %}
39
40{% func GitItemNav (name, ref string, s GitSelection) %}
41<div class="row">
42 <h3 id="name">{%s name %} {% if ref != "" && (s == Log || s == Tree) %}@ {%s ref %}{% endif %}</h3>
43</div>
44<div class="row">
45 <ul class="nav">
46 <li class="nav-item">
47 <a class="nav-link{%= insertIfEqual(s, Readme) %}" aria-current="page" href="/{%s name %}/about/">about</a>
48 </li>
49 <li class="nav-item">
50 <a class="nav-link{%= insertIfEqual(s, Summary) %}" aria-current="page" href="/{%s name %}/">summary</a>
51 </li>
52 <li class="nav-item">
53 <a class="nav-link{%= insertIfEqual(s, Refs) %}" aria-current="page" href="/{%s name %}/refs">refs</a>
54 </li>
55 <li class="nav-item">
56 <a class="nav-link{%= insertIfEqual(s, Log) %}" aria-current="page" href="/{%s name %}/log/{%s ref %}/">log</a>
57 </li>
58 <li class="nav-item">
59 <a class="nav-link{%= insertIfEqual(s, Tree) %}" aria-current="page" href="/{%s name %}/tree/{%s ref %}/">tree</a>
60 </li>
61 </ul>
62</div>
63{% endfunc %}