File tree Expand file tree Collapse file tree 4 files changed +27
-3
lines changed Expand file tree Collapse file tree 4 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 1+ 'use strict'
2+
3+ module . exports = (
4+ navigation ,
5+ {
6+ data : {
7+ root : { page } ,
8+ } ,
9+ }
10+ ) => {
11+ traceCurrentPathInternal ( navigation , page . url )
12+ return navigation
13+ }
14+
15+ function traceCurrentPathInternal ( items , currentPageUrl , path = [ ] ) {
16+ for ( const item of items ) {
17+ if ( item . url === currentPageUrl ) {
18+ for ( const ancestor of path ) ancestor . current = 'path'
19+ item . current = 'page'
20+ return true
21+ }
22+ if ( item . items && traceCurrentPathInternal ( item . items , currentPageUrl , path . concat ( item ) ) ) return true
23+ }
24+ }
Original file line number Diff line number Diff line change 1616 var currentPageItem = menuPanel . querySelector ( '.is-current-page' )
1717 var originalPageItem = currentPageItem
1818 if ( currentPageItem ) {
19- activateCurrentPath ( currentPageItem )
19+ // activateCurrentPath(currentPageItem) // enable if not handled by template
2020 scrollItemToMidpoint ( menuPanel , currentPageItem . querySelector ( '.nav-link' ) )
2121 } else {
2222 menuPanel . scrollTop = 0
Original file line number Diff line number Diff line change 55 {{ #with @root.page.componentVersion }}
66 <h3 class =" title" ><a href =" {{{ relativize ./url }}} " >{{ ./title }} </a ></h3 >
77 {{ /with }}
8- {{> nav-tree navigation =this }}
8+ {{> nav-tree navigation =( traceCurrentPath this ) }}
99 </nav >
1010</div >
1111{{ /with }}
Original file line number Diff line number Diff line change 11{{ #if navigation.length }}
22<ul class =" nav-list" >
33 {{ #each navigation }}
4- <li class =" nav-item{{ #if ( eq ./url @ root.page.url ) }} is-current-page {{ /if }} " data-depth =" {{ or ../level 0 }} " >
4+ <li class =" nav-item{{ #with ./current }} is-current-{{{ this }}} is-active {{ /with }} " data-depth =" {{ or ../level 0 }} " >
55 {{ #if ./content }}
66 {{ #if ./items.length }}
77 <button class =" nav-item-toggle" ></button >
You can’t perform that action at this time.
0 commit comments