(currentPath, tree)
| 63 | // ] |
| 64 | // |
| 65 | function traverseTreeTitles(currentPath, tree) { |
| 66 | const { href, title, shortTitle } = tree |
| 67 | const crumbs = [ |
| 68 | { |
| 69 | href, |
| 70 | title: shortTitle || title, |
| 71 | }, |
| 72 | ] |
| 73 | const currentPathSplit = Array.isArray(currentPath) ? currentPath : currentPath.split('/') |
| 74 | for (const child of tree.childPages) { |
| 75 | if (isParentOrEqualArray(child.href.split('/'), currentPathSplit)) { |
| 76 | crumbs.push(...traverseTreeTitles(currentPathSplit, child)) |
| 77 | // Only ever going down 1 of the children |
| 78 | break |
| 79 | } |
| 80 | } |
| 81 | return crumbs |
| 82 | } |
| 83 | |
| 84 | // Return true if an array is part of another array or equal. |
| 85 | // Like `/foo/bar` is part of `/foo/bar/buzz`. |
no test coverage detected