UNPKG

@mdfriday/foundry

Version:

The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.

179 lines 4.14 kB
/** * MenuEntry - A single menu item with hierarchical support * TypeScript equivalent based on menu.md requirements */ export declare class MenuEntry { private readonly _title; private readonly _url; private readonly _isDir; private readonly _hasIndex; private readonly _children; private readonly _weight; private readonly _identifier; constructor(options: { title: string; url: string; isDir: boolean; hasIndex: boolean; children?: MenuEntry[]; weight?: number; identifier?: string; }); /** * Get menu entry title */ title(): string; /** * Get menu entry URL */ url(): string; /** * Check if this is a directory (branch) */ isDirectory(): boolean; /** * Check if this directory has an index page (leaf) */ hasIndex(): boolean; /** * Get child menu entries */ children(): MenuEntry[]; /** * Get menu entry weight for sorting */ weight(): number; /** * Get menu entry identifier */ identifier(): string; /** * Check if this menu entry has children */ hasChildren(): boolean; /** * Add a child menu entry */ addChild(child: MenuEntry): MenuEntry; /** * Convert to JSON representation as specified in menu.md */ toJSON(): any; /** * Create a new MenuEntry with updated properties */ withChildren(children: MenuEntry[]): MenuEntry; } /** * Menu - A collection of menu entries with sorting and filtering capabilities */ export declare class Menu { private readonly _entries; constructor(entries?: MenuEntry[]); /** * Get all entries */ entries(): MenuEntry[]; /** * Get entry by index */ get(index: number): MenuEntry | undefined; /** * Get length */ get length(): number; /** * Add a menu entry */ add(entry: MenuEntry): Menu; /** * Sort menu entries by weight and then by title */ sortMenu(): Menu; /** * Filter menu entries by predicate */ filterMenu(predicate: (entry: MenuEntry) => boolean): Menu; /** * Find menu entry by identifier */ findByIdentifier(identifier: string): MenuEntry | undefined; /** * Find menu entry by URL */ findByUrl(url: string): MenuEntry | undefined; /** * Get all leaf entries (entries without children) */ getLeaves(): Menu; /** * Get all branch entries (entries with children) */ getBranches(): Menu; /** * Convert to JSON array */ toJSON(): any[]; /** * Iterator support */ [Symbol.iterator](): Iterator<MenuEntry>; /** * Map over entries */ map<T>(callback: (entry: MenuEntry, index: number) => T): T[]; /** * ForEach over entries */ forEach(callback: (entry: MenuEntry, index: number) => void): void; } /** * Menus - A collection of menus by name, supporting multiple languages * TypeScript equivalent of valueobject.Menus from Go */ export declare class Menus { private readonly _menus; constructor(menus?: Map<string, Menu>); /** * Get menu by name */ get(name: string): Menu | undefined; /** * Set menu by name */ set(name: string, menu: Menu): Menus; /** * Get all menu names */ names(): string[]; /** * Check if menu exists */ has(name: string): boolean; /** * Check if menu entry has sub-menu */ hasSubMenu(entry: MenuEntry): boolean; /** * Get all menus as entries */ entries(): [string, Menu][]; /** * Convert to plain object for serialization */ toJSON(): Record<string, any[]>; /** * Merge with another Menus instance */ merge(other: Menus): Menus; } /** * Create empty menus instance */ export declare function newEmptyMenus(): Menus; /** * Menu constants */ export declare const MENUS_AFTER = "after"; export declare const MENUS_BEFORE = "before"; //# sourceMappingURL=menu.d.ts.map