(req, isEarlyAccess)
| 18 | const earlyAccessExceptions = ['insights', 'enterprise-importer'] |
| 19 | |
| 20 | function getBreadcrumbs(req, isEarlyAccess) { |
| 21 | let cutoff = 0 |
| 22 | // When in Early access docs consider the "root" be much higher. |
| 23 | // E.g. /en/early-access/github/migrating/understanding/about |
| 24 | // we only want it start at /migrating/understanding/about |
| 25 | // Essentially, we're skipping "/early-access" and its first |
| 26 | // top-level like "/github" |
| 27 | if (isEarlyAccess) { |
| 28 | const split = req.context.currentPath.split('/') |
| 29 | // There are a few exceptions to this rule for the |
| 30 | // /{version}/early-access/<product-name>/... URLs because they're a |
| 31 | // bit different. |
| 32 | // If there are more known exceptions, add them to the array above. |
| 33 | if (earlyAccessExceptions.some((product) => split.includes(product))) { |
| 34 | cutoff = 1 |
| 35 | } else { |
| 36 | cutoff = 2 |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | const breadcrumbs = traverseTreeTitles( |
| 41 | req.context.currentPath, |
| 42 | req.context.currentProductTreeTitles |
| 43 | ) |
| 44 | ;[...Array(cutoff)].forEach(() => breadcrumbs.shift()) |
| 45 | |
| 46 | return breadcrumbs |
| 47 | } |
| 48 | |
| 49 | // Return an array as if you'd traverse down a tree. Imagine a tree like |
| 50 | // |
no test coverage detected