[OCaml] Mobile-friendly clone of cgit.
feat show commit type pill on individual commit detail pages
Parse the commit summary with parse_conventional on the /commit/:id page and display the pill inline in the h3 heading, linking back to the filtered commits list. This makes the pill a ubiquitous element of the design language across commit list, commit detail, and summary views.
lib/views/repo.ml
@@ -310,9 +310,21 @@
310
310
| [] -> HTML.[ p [] [ txt "No file changes in this commit." ] ]
311
311
| files -> List.map file files
312
312
in
313
Added:
let commit_type, commit_title = parse_conventional message.summary in
314
Added:
let pill =
315
Added:
match commit_type with
316
Added:
| None -> HTML.null []
317
Added:
| Some ct ->
318
Added:
HTML.(
319
Added:
span
320
Added:
[ class_ "commit-pill commit-pill-%s" ct ]
321
Added:
[
322
Added:
a [ href "/%s/commits/?type=%s" context.repo ct ] [ txt "%s" ct ];
323
Added:
])
324
Added:
in
313
325
let content =
314
326
HTML.(
315
Removed:
[ h3 [] [ txt "%s" message.summary ] ]
327
Added:
[ h3 [] [ pill; txt " %s" commit_title ] ]
316
328
@ (if message.body = "" then []
317
329
else [ p [ class_ "commit-body" ] [ txt "%s" message.body ] ])
318
330
@ [