From fbeebd0fba44c05c72d96db6f78defb97c5188f4 Mon Sep 17 00:00:00 2001 From: Paul Robert Lloyd Date: Sat, 9 Dec 2023 00:16:58 +0000 Subject: [PATCH] Add href to current item in navigation --- lib/filters/items-from-navigation.js | 1 + test/lib/filters/items-from-navigation.mjs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/filters/items-from-navigation.js b/lib/filters/items-from-navigation.js index 10afbf50..125f35ef 100644 --- a/lib/filters/items-from-navigation.js +++ b/lib/filters/items-from-navigation.js @@ -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 => ({ diff --git a/test/lib/filters/items-from-navigation.mjs b/test/lib/filters/items-from-navigation.mjs index b845ef5c..6e52a838 100644 --- a/test/lib/filters/items-from-navigation.mjs +++ b/test/lib/filters/items-from-navigation.mjs @@ -62,6 +62,7 @@ describe('itemsFromNavigation filter', () => { current: false }] }, { + href: '/parent/child', text: 'Child page', current: true, parent: true, @@ -120,6 +121,7 @@ describe('itemsFromNavigation filter', () => { current: false }] }, { + href: '/prefix/parent/child', text: 'Child page', current: true, parent: true, @@ -156,6 +158,7 @@ describe('itemsFromNavigation filter', () => { current: false }] }, { + href: '/parent/child', text: 'Child page', current: true, parent: true, @@ -193,6 +196,7 @@ describe('itemsFromNavigation filter', () => { current: false }] }, { + href: '/prefix/parent/child', text: 'Child page', current: true, parent: true,