All files / packages/design-system-2-site/src/lib parse-navigation-md.ts

100% Statements 3/3
100% Branches 4/4
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20                              17x 17x 17x    
import fs from 'node:fs';
import path from 'node:path';
import { parseNavigationMdString } from './nav-md-parser.js';
import type { NavCategory, NavGroup, NavPage, NavTab } from './nav-md-parser.js';
 
export type { NavCategory, NavGroup, NavPage, NavTab };
 
/**
 * Load and parse the site's `navigation.md`.
 *
 * The parsing rules live in `nav-md-parser.mjs` so they can be shared with
 * `scripts/verify-navigation.mjs` (a plain-node prebuild step).
 */
export function parseNavigationMd(filePath?: string): NavCategory[] {
  const mdPath =
    filePath ?? path.join(process.env.CONTENT_DIR || path.resolve(process.cwd(), 'content'), 'navigation.md');
  const raw = fs.readFileSync(mdPath, 'utf-8');
  return parseNavigationMdString(raw);
}