cerrado @ 57efc8d2173fdff1ef99157a2633d3f1d366a290

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