Skip to content

Commit

Permalink
Add href to current item in navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Dec 9, 2023
1 parent 605e332 commit fbeebd0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/filters/items-from-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = (eleventyNavigation, pageUrl = false, options = {}) => {
const navItem = {
current: isCurrentPage,
parent: pageUrl ? pageUrl.startsWith(item.url, pathPrefix) : false,
href: url(item.url, pathPrefix),
text: smart(item.title),
children: item.children
? item.children.map(child => ({
Expand Down
4 changes: 4 additions & 0 deletions test/lib/filters/items-from-navigation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('itemsFromNavigation filter', () => {
current: false
}]
}, {
href: '/parent/child',
text: 'Child page',
current: true,
parent: true,
Expand Down Expand Up @@ -120,6 +121,7 @@ describe('itemsFromNavigation filter', () => {
current: false
}]
}, {
href: '/prefix/parent/child',
text: 'Child page',
current: true,
parent: true,
Expand Down Expand Up @@ -156,6 +158,7 @@ describe('itemsFromNavigation filter', () => {
current: false
}]
}, {
href: '/parent/child',
text: 'Child page',
current: true,
parent: true,
Expand Down Expand Up @@ -193,6 +196,7 @@ describe('itemsFromNavigation filter', () => {
current: false
}]
}, {
href: '/prefix/parent/child',
text: 'Child page',
current: true,
parent: true,
Expand Down

0 comments on commit fbeebd0

Please sign in to comment.