️ Add support for aria-current in menus

This commit is contained in:
Kazhnuz 2025-08-22 23:31:03 +02:00
parent 063751a568
commit fae2fe7d42
2 changed files with 10 additions and 3 deletions

View file

@ -20,7 +20,9 @@ class Link {
function isActive() function isActive()
{ {
return false; global $url;
global $site;
return str_ends_with($this->href, $url->uri()) || ($this->href == $site->url() && $url->uri() == "/");
} }
function haveClass() function haveClass()
@ -35,6 +37,6 @@ class Link {
function toHTML() function toHTML()
{ {
return "<a href='" . $this->href . "' " . ($this->haveClass() ? "class='" . $this->getClasses() . "'" : "" ) . " >".$this->label."</a>"; return "<a href='" . $this->href . "' " . ($this->haveClass() ? "class='" . $this->getClasses() . "'" : "" ) . ($this->isActive() ? "aria-current='page'" : "") . " >".$this->label."</a>";
} }
} }

View file

@ -51,7 +51,8 @@ header#main-header {
border-radius: var(--border-radius); border-radius: var(--border-radius);
padding:8px; padding:8px;
} }
a:hover { a:hover,
a.active {
background-color: rgba(255,255,255,0.2); background-color: rgba(255,255,255,0.2);
} }
} }
@ -129,6 +130,10 @@ aside {
.plugin { .plugin {
margin-bottom: 1rem; margin-bottom: 1rem;
} }
a.active {
font-weight: bold;
}
} }
nav ul { nav ul {