import { DocsSidebar } from "~/application/sidebar/DocsSidebar"; import { SideBarItem } from "~/application/sidebar/SidebarItem"; import type { CommandAction } from "~/services/command-registry/commandRegistry"; export function getDocCommands(): CommandAction[] { const commands: CommandAction[] = []; DocsSidebar().forEach((item) => { commands.push(...getCommandsFromItem(item, [], [])); }); return commands; } function getCommandsFromItem(item: SideBarItem, commands: CommandAction[], parent: string[]) { if (item.path && item.title) { let description = item.description ?? ""; if (parent.length > 0) { description = parent.join(" / "); } commands.push({ id: item.path, name: item.title, shortcut: [], subtitle: description, }); } item.items?.forEach((subItem) => { return getCommandsFromItem(subItem, commands, [...parent, item.title]); }); return commands; }