♿️ Add support for aria-current in menus
This commit is contained in:
parent
063751a568
commit
fae2fe7d42
2 changed files with 10 additions and 3 deletions
|
@ -20,7 +20,9 @@ class Link {
|
|||
|
||||
function isActive()
|
||||
{
|
||||
return false;
|
||||
global $url;
|
||||
global $site;
|
||||
return str_ends_with($this->href, $url->uri()) || ($this->href == $site->url() && $url->uri() == "/");
|
||||
}
|
||||
|
||||
function haveClass()
|
||||
|
@ -35,6 +37,6 @@ class Link {
|
|||
|
||||
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>";
|
||||
}
|
||||
}
|
|
@ -51,7 +51,8 @@ header#main-header {
|
|||
border-radius: var(--border-radius);
|
||||
padding:8px;
|
||||
}
|
||||
a:hover {
|
||||
a:hover,
|
||||
a.active {
|
||||
background-color: rgba(255,255,255,0.2);
|
||||
}
|
||||
}
|
||||
|
@ -129,6 +130,10 @@ aside {
|
|||
.plugin {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
a.active {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
nav ul {
|
||||
|
|
Loading…
Add table
Reference in a new issue