Skip to content

Commit

Permalink
fix set current url
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Sep 16, 2024
1 parent d0c7f1d commit 4f64477
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ customElements.define(

if (data.url) {
const a = document.createElement("a");
a.href = new URL(`.${data.url}`, baseUrl).href;
const href = new URL(`.${data.url}`, baseUrl).pathname;
a.href = href;
a.textContent = data.title || slug;

if (data.url === url) {
if (href === url) {
a.setAttribute("aria-current", "page");
}
li.appendChild(a);
Expand Down

0 comments on commit 4f64477

Please sign in to comment.