diff options
| author | Joe Mou <dev@mou.fo> | 2026-09-18 07:27:21 +0100 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2026-09-18 07:27:21 +0100 |
| commit | 9659525bf2387af6deab9d401784b94b1f44d395 (patch) | |
| tree | c67dc1dd05bf2a8fa48dc123d6353d255a658ef1 /cgithub/views/_nav.eta | |
| parent | 9819d8e5504d6f03d27ec6b8786eec8fe5a752a5 (diff) | |
| parent | 01494e6fa1345a509560e5e19a7f08cb2aac5cc8 (diff) | |
Diffstat (limited to 'cgithub/views/_nav.eta')
| -rw-r--r-- | cgithub/views/_nav.eta | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/cgithub/views/_nav.eta b/cgithub/views/_nav.eta new file mode 100644 index 0000000..a20741b --- /dev/null +++ b/cgithub/views/_nav.eta @@ -0,0 +1,34 @@ +<section> + <% + const isCommitHash = /^[0-9a-f]{40}$/.test(it.branch); + const refLabel = isCommitHash ? it.branch.slice(0, 7) : it.branch; + %> + <button type="button" class="ref-selector-button branch" command="show-modal" commandfor="ref-selector-menu"> + <img src="/static/icons/git-branch.svg" alt="branch" class="icon"> <%= refLabel %> ▾ + </button> + <dialog class="ref-selector-menu" id="ref-selector-menu" closedby="any" data-owner="<%= it.repo.owner %>" data-repo="<%= it.repo.name %>" data-view="<%= it.view %>"<% if (it.path && it.path !== "/") { %> data-path="<%= it.path %>"<% } %>> + <div class="ref-selector-tabs"> + <button type="button" class="active" data-ref-type="branches">Branches</button> + <button type="button" data-ref-type="tags">Tags</button> + </div> + <div class="ref-selector-list">Loading…</div> + </dialog> + <% if (it.path && it.path !== "/") { %> + <% + const crumbHrefBase = `/${it.repo.owner}/${it.repo.name}/${it.view === "blob" ? "tree" : it.view}/${it.branch}`; + %> + <a href="<%= crumbHrefBase %>">(top)</a><% + const pathParts = it.path.split('/').filter(p => p); + let currentPath = ''; + for (let i = 0; i < pathParts.length; i++) { + const part = pathParts[i]; + currentPath += (currentPath ? '/' : '') + part; + const isLast = i === pathParts.length - 1; + if (isLast) { + %>/<%= part %><%= it.view === "tree" ? "/" : "" %><% + } else { + %>/<a href="<%= crumbHrefBase %>/<%= currentPath %>"><%= part %></a><% + } + } %> + <% } %> +</section> |
