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 <a class="nav-link{%= insertIfEqual(s, Config) %}" href="/config">config</a>
37 </div>
38 </nav>
39{% endfunc %}
40
41{% func GitItemNav (name, ref string, s GitSelection) %}
42<div class="row">
43 <h3 id="name">{%s name %} {% if ref != "" && (s == Log || s == Tree) %}@ {%s ref %}{% endif %}</h3>
44</div>
45<div class="row">
46 <ul class="nav">
47 <li class="nav-item">
48 <a class="nav-link{%= insertIfEqual(s, Readme) %}" aria-current="page" href="/{%s name %}/about/">about</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, Log) %}" aria-current="page" href="/{%s name %}/log/{%s ref %}/">log</a>
58 </li>
59 <li class="nav-item">
60 <a class="nav-link{%= insertIfEqual(s, Tree) %}" aria-current="page" href="/{%s name %}/tree/{%s ref %}/">tree</a>
61 </li>
62 </ul>
63</div>
64{% endfunc %}