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