-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from couchbase/hakim-top-nav-highlight
AV-75840 top nav highlight
- Loading branch information
Showing
5 changed files
with
75 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
'use strict' | ||
|
||
module.exports = (haystack, needle) => ~(haystack || '').indexOf(needle) | ||
module.exports = (haystack, needle) => { | ||
return ~(haystack || '').indexOf(needle) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict' | ||
|
||
module.exports = module.exports = (navGroup, { | ||
data: { | ||
root: { page, site }, | ||
}, | ||
}) => { | ||
if (navGroup === 'home') { | ||
// FAKE value to signal that we instead check all the navgroups | ||
const navGroups = site.keys.navGroups | ||
// NB this relies on variable stored in site.keys, so must be called | ||
// *after* nav-groups has already prepared the data | ||
const possible = navGroups.filter((it) => selected(it, page)) | ||
return possible.length === 1 && possible[0].title === 'Home' | ||
} else { | ||
return selected(navGroup, page) | ||
} | ||
} | ||
|
||
function selected (navGroup, page) { | ||
return (navGroup.url === page?.url) || | ||
(navGroup.components?.includes(page.component?.name)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters