UNPKG

element-book

Version:

An [`element-vir`](https://npmjs.com/package/element-vir) drop-in element for building, testing, and demonstrating a collection of elements (or, in other words, a design system).

16 lines (15 loc) 635 B
import { check } from '@augment-vir/assert'; import { BookEntryType } from '../../../data/book-entry/book-entry-type.js'; export function shouldShowTreeNodeInNav(currentNode, selectedPath) { if (currentNode.entry.entryType === BookEntryType.Root) { return false; } if (currentNode.entry.entryType === BookEntryType.Page) { return true; } const isParentSelected = check.jsonEquals(selectedPath, currentNode.fullUrlBreadcrumbs.slice(0, -1)); if (isParentSelected) { return true; } return check.jsonEquals(selectedPath?.slice(0, -1), currentNode.fullUrlBreadcrumbs.slice(0, -1)); }