[OCaml] Mobile-friendly clone of cgit.
feat add 'root' prefix link in breadcrumb path pill
The path pill now always starts with a 'root' link pointing to the files listing root, followed by slash-separated links for each trail segment. This allows navigating back to the project root from any depth, matching cgit's breadcrumb behaviour.
lib/views/repo.ml
@@ -314,20 +314,26 @@
314
314
]
315
315
316
316
let breadcrumb_pill repo (trail : (string * string) list) =
317
Removed:
match trail with
318
Removed:
| [] -> HTML.null []
319
Removed:
| _ ->
320
Removed:
let segment i (entry_name, hash) =
321
Removed:
let anchor =
322
Removed:
Routes.link_to
323
Removed:
(File (repo, hash))
324
Removed:
~other_attrs:[ HTML.class_ "path-pill-link" ]
325
Removed:
(txt "%s" entry_name)
326
Removed:
in
327
Removed:
if i = 0 then anchor
328
Removed:
else HTML.(null [ span [ class_ "path-pill-sep" ] [ txt "/" ]; anchor ])
329
Removed:
in
330
Removed:
HTML.(span [ class_ "path-pill" ] (List.mapi segment trail))
317
Added:
let root_anchor =
318
Added:
Routes.link_to (Files repo)
319
Added:
~other_attrs:[ HTML.class_ "path-pill-link" ]
320
Added:
(txt "root")
321
Added:
in
322
Added:
let segments =
323
Added:
List.map
324
Added:
(fun (entry_name, hash) ->
325
Added:
HTML.(
326
Added:
null
327
Added:
[
328
Added:
span [ class_ "path-pill-sep" ] [ txt "/" ];
329
Added:
Routes.link_to
330
Added:
(File (repo, hash))
331
Added:
~other_attrs:[ class_ "path-pill-link" ]
332
Added:
(txt "%s" entry_name);
333
Added:
]))
334
Added:
trail
335
Added:
in
336
Added:
HTML.(span [ class_ "path-pill" ] (root_anchor :: segments))
331
337
332
338
let files context trail (entries : Resolvers.Tree.preloaded_entry list) =
333
339
let pill = breadcrumb_pill context.repo trail in