Skip to content

Commit

Permalink
Only highlight home page in navigation when visiting home page
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Dec 22, 2023
1 parent 7fe9b44 commit a625049
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/filters/current-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
*/
module.exports = (array, pageUrl) => {
return array.map((item) => {
item.current = pageUrl.startsWith(item.href)
item.current =
item.href === '/'
? pageUrl === '/' // Page is home page
: pageUrl.startsWith(item.href) // Page is within navigation section

return item
})
Expand Down

0 comments on commit a625049

Please sign in to comment.