Shared utility module providing path and slug operations for document source viewers (knowledge base, data room, etc.), serving as the single source of truth for path normalization across route handlers. ## Key Components | Export | Signature | Purpose | |--------|-----------|---------| | `toDocSlug` | `(name: string) => string` | Converts a display name to a URL-safe slug | | `pathToNodeId` | `(path: string) => string` | Converts a file path to a DOM-safe node ID | | `normalizeDocPath` | `(segments: string[], folderIndexFile?: string) => string` | Normalizes URL path segments, stripping folder-index suffixes | ## Usage Example ```typescript import { toDocSlug, pathToNodeId, normalizeDocPath } from './doc-path-utils' // Convert document name to URL slug toDocSlug('Investor Thesis') // → "investor-thesis" toDocSlug(' Cap Table ') // → "cap-table" // Convert file path to a DOM-safe tree node ID pathToNodeId('legal/cap-table/safe.md') // → "legal-cap-table-safe.md" // Normalize route segments, stripping README.md index suffixes normalizeDocPath(['legal', 'cap-table']) // → "legal/cap-table" normalizeDocPath(['legal', 'cap-table', 'README.md']) // → "legal/cap-table" normalizeDocPath(['README.md']) // → "" // Override the default folder-index filename normalizeDocPath(['docs', 'index.md'], 'index.md') // → "docs" ``` ## Notes - `normalizeDocPath` lowercases **both** the input segments and the `folderIndexFile` constant before comparison, ensuring URLs like `readme.md` and `README.md` strip uniformly. - `DEFAULT_FOLDER_INDEX_FILE` is imported from `doc-tree-nav` and used as the default `folderIndexFile` argument. **Source:** [`doc-path-utils.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/doc-path-utils.ts)