| 1 | namespace AgentForge.Plugin.View.Components.Code; |
| 2 | |
| 3 | internal static class ForgeViewCodeNav |
| 4 | { |
| 5 | internal static string Render( |
| 6 | string repoName, |
| 7 | string activeBranch, |
| 8 | IReadOnlyList<string> branches, |
| 9 | string? path, |
| 10 | bool isBlob, |
| 11 | string? commitTip = null) |
| 12 | { |
| 13 | var branchPicker = ForgeViewBranchPicker.Render(repoName, activeBranch, branches, path, isBlob); |
| 14 | var crumb = ForgeViewPathCrumb.Render(repoName, activeBranch, path, isBlob); |
| 15 | var metaParts = new List<string>(); |
| 16 | |
| 17 | if (isBlob) |
| 18 | { |
| 19 | var language = ForgeSyntaxHighlighter.LanguageFromPath(path); |
| 20 | if (!string.IsNullOrEmpty(language)) |
| 21 | metaParts.Add(ForgeHtml.Span("lang-badge", ForgeHtml.Text(language))); |
| 22 | } |
| 23 | |
| 24 | if (!string.IsNullOrEmpty(commitTip)) |
| 25 | { |
| 26 | metaParts.Add(ForgeHtml.Code( |
| 27 | commitTip[..Math.Min(8, commitTip.Length)], |
| 28 | "commit-sha", |
| 29 | commitTip)); |
| 30 | } |
| 31 | |
| 32 | return ForgeHtml.Div("code-nav", |
| 33 | branchPicker, |
| 34 | ForgeHtml.Nav("path-crumb", "Path", crumb), |
| 35 | ForgeHtml.Span("code-nav-meta", [.. metaParts])); |
| 36 | } |
| 37 | } |
| 38 | |