github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/app/controller/cmenu/breadcrumbs.go (about) 1 // Package cmenu - Content managed by Project Forge, see [projectforge.md] for details. 2 package cmenu 3 4 import ( 5 "github.com/kyleu/dbaudit/app/lib/menu" 6 ) 7 8 type Breadcrumbs []string 9 10 func (b Breadcrumbs) Active(i *menu.Item, path []string) (bool, bool) { 11 for idx, x := range path { 12 if len(b) <= idx || b[idx] != x { 13 return false, false 14 } 15 } 16 if len(i.Children) == 0 { 17 return true, true 18 } 19 if len(path) == len(b) { 20 return true, true 21 } 22 if len(path) < len(b) { 23 next := b[len(path)] 24 for _, kid := range i.Children { 25 if kid.Key == next { 26 return true, false 27 } 28 } 29 } 30 return true, true 31 }