Make use of aria-current as selector and remove use of active class.

This commit is contained in:
Fredrik Jonsson 2023-05-30 08:57:59 +02:00
commit 93728f1e9e
5 changed files with 17 additions and 15 deletions

View file

@ -196,17 +196,13 @@ figure {
} }
&:active, &:active,
&.active { &[aria-current] {
background-color: var(--color-brand); background-color: var(--color-brand);
text-decoration: underline; text-decoration: underline;
} }
} }
} }
.menu a.active {
text-decoration: none;
}
// Search // Search
.search-text { .search-text {

View file

@ -32,6 +32,12 @@ a:active {
color: var(--color-link-active); color: var(--color-link-active);
} }
// Remove underline from links to current page to
// indicate that there is no need to click on it.
[aria-current] {
text-decoration: none;
}
.link-nav, .link-nav,
%link-nav { %link-nav {
a { a {

View file

@ -4,7 +4,7 @@
{{ $currentPage := . -}} {{ $currentPage := . -}}
{{ range site.Menus.main -}} {{ range site.Menus.main -}}
<li><a href="{{ .URL | relLangURL }}"{{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} class="active" aria-current="page"{{ end }}>{{ .Pre }}<span>{{ .Name }}</span>{{ .Post }}</a></li> <li><a href="{{ .URL | relLangURL }}"{{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} aria-current="page"{{ end }}>{{ .Pre }}<span>{{ .Name }}</span>{{ .Post }}</a></li>
{{ end -}} {{ end -}}
{{ else -}} {{ else -}}
@ -12,12 +12,12 @@
{{ $currentSection := .Section -}} {{ $currentSection := .Section -}}
{{ $currentID := "" -}} {{ $currentID := "" -}}
{{ with .File }}{{ $currentID = .UniqueID }}{{ end -}} {{ with .File }}{{ $currentID = .UniqueID }}{{ end -}}
{{ with site.Home }}<li><a href="{{ .RelPermalink }}"{{ if eq $currentID .File.UniqueID }} class="active" aria-current="page"{{ end }}>{{ i18n "menu_home" }}</a></li>{{ end }} {{ with site.Home }}<li><a href="{{ .RelPermalink }}"{{ if eq $currentID .File.UniqueID }} aria-current="page"{{ end }}>{{ i18n "menu_home" }}</a></li>{{ end }}
{{ range where site.RegularPages "Section" "" -}} {{ range where site.RegularPages "Section" "" -}}
<li><a href="{{ .RelPermalink }}"{{ if eq $currentID .File.UniqueID }} class="active" aria-current="page"{{ end }}>{{ .Title }}</a></li> <li><a href="{{ .RelPermalink }}"{{ if eq $currentID .File.UniqueID }} aria-current="page"{{ end }}>{{ .Title }}</a></li>
{{ end -}} {{ end -}}
{{ range site.Sections -}} {{ range site.Sections -}}
<li><a href="{{ .RelPermalink }}"{{ if eq $currentSection .Section }} class="active" aria-current="page"{{ end }}>{{ .Title }}</a></li> <li><a href="{{ .RelPermalink }}"{{ if eq $currentSection .Section }} aria-current="page"{{ end }}>{{ .Title }}</a></li>
{{ end -}} {{ end -}}
{{ end -}} {{ end -}}

View file

@ -16,7 +16,7 @@
{{ $currentPage := . -}} {{ $currentPage := . -}}
{{ range site.Menus.main -}} {{ range site.Menus.main -}}
<li><a href="{{ .URL | relLangURL }}"{{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} class="active" aria-current="page"{{ end }}>{{ .Pre }}<span>{{ .Name }}</span>{{ .Post }}</a></li> <li><a href="{{ .URL | relLangURL }}"{{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} aria-current="page"{{ end }}>{{ .Pre }}<span>{{ .Name }}</span>{{ .Post }}</a></li>
{{ end -}} {{ end -}}
{{ else -}} {{ else -}}
@ -24,12 +24,12 @@
{{ $currentSection := .Section -}} {{ $currentSection := .Section -}}
{{ $currentID := "" -}} {{ $currentID := "" -}}
{{ with .File }}{{ $currentID = .UniqueID }}{{ end -}} {{ with .File }}{{ $currentID = .UniqueID }}{{ end -}}
{{ with site.Home }}<li><a href="{{ .RelPermalink }}"{{ if eq $currentID .File.UniqueID }} class="active" aria-current="page"{{ end }}>{{ i18n "menu_home" }}</a></li>{{ end }} {{ with site.Home }}<li><a href="{{ .RelPermalink }}"{{ if eq $currentID .File.UniqueID }} aria-current="page"{{ end }}>{{ i18n "menu_home" }}</a></li>{{ end }}
{{ range where site.RegularPages "Section" "" -}} {{ range where site.RegularPages "Section" "" -}}
<li><a href="{{ .RelPermalink }}"{{ if eq $currentID .File.UniqueID }} class="active" aria-current="page"{{ end }}>{{ .Title }}</a></li> <li><a href="{{ .RelPermalink }}"{{ if eq $currentID .File.UniqueID }} aria-current="page"{{ end }}>{{ .Title }}</a></li>
{{ end -}} {{ end -}}
{{ range site.Sections -}} {{ range site.Sections -}}
<li><a href="{{ .RelPermalink }}"{{ if eq $currentSection .Section }} class="active" aria-current="page"{{ end }}>{{ .Title }}</a></li> <li><a href="{{ .RelPermalink }}"{{ if eq $currentSection .Section }} aria-current="page"{{ end }}>{{ .Title }}</a></li>
{{ end -}} {{ end -}}
{{ end -}} {{ end -}}

View file

@ -4,10 +4,10 @@
<aside class="sidebar layout__second-sidebar"> <aside class="sidebar layout__second-sidebar">
{{ range site.Sections -}} {{ range site.Sections -}}
<section class="menu"> <section class="menu">
<p class="title"><strong><a href="{{ .RelPermalink }}"{{ if eq $currentSection .Section }} class="active" aria-current="page"{{ end }}>{{ .Title }}</a></strong></p> <p class="title"><strong><a href="{{ .RelPermalink }}"{{ if eq $currentSection .Section }} aria-current="page"{{ end }}>{{ .Title }}</a></strong></p>
<ul> <ul>
{{ range .Pages -}} {{ range .Pages -}}
<li><a href="{{ .RelPermalink }}"{{ if eq $currentID .File.UniqueID }} class="active" aria-current="page"{{ end }}>{{ .Title }}</a></li> <li><a href="{{ .RelPermalink }}"{{ if eq $currentID .File.UniqueID }} aria-current="page"{{ end }}>{{ .Title }}</a></li>
{{ end -}} {{ end -}}
</ul> </ul>
</section> </section>