From e1b24b557d00407fb96755c34a8956afff56a51a Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 26 Sep 2026 08:38:40 -1000 Subject: Add stable markup hooks for site themes --- source/ui-shared.c | 51 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 14 deletions(-) (limited to 'source/ui-shared.c') diff --git a/source/ui-shared.c b/source/ui-shared.c index 4417975..0f2f1e3 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -104,6 +104,22 @@ static void site_url(const char *page, const char *search, const char *sort, int } } +/* + * Write the class of a link, and mark the link as the current one for + * assistive technology when the class says it is the active tab or the + * current page of a pager. + */ +static void link_class(const char *class) +{ + if (!class) + return; + html(" class='"); + html_attr(class); + html("'"); + if (!strcmp(class, "active") || !strcmp(class, "current")) + html(" aria-current='page'"); +} + static void site_link(const char *page, const char *name, const char *title, const char *class, const char *search, const char *sort, int ofs, int always_root) { @@ -113,11 +129,7 @@ static void site_link(const char *page, const char *name, const char *title, html_attr(title); html("'"); } - if (class) { - html(" class='"); - html_attr(class); - html("'"); - } + link_class(class); html(" href='"); site_url(page, search, sort, ofs, always_root); html("'>"); @@ -142,11 +154,7 @@ static const char *repolink(const char *title, const char *class, const char *pa html_attr(title); html("'"); } - if (class) { - html(" class='"); - html_attr(class); - html("'"); - } + link_class(class); html(" href='"); if (ctx.cfg.virtual_root) { html_url_path(ctx.cfg.virtual_root); @@ -631,7 +639,7 @@ static void print_repo_tabs(void) static void print_repo_search(void) { - html("