// lib/api/menu-api.ts
import { fetchGraphQL } from './graphql-client.js';
export interface MenuItem {
id: string;
databaseId: number;
uri: string;
url: string;
order: number;
label: string;
parentId: string | null;
target: string;
cssClasses: string[];
description: string;
childItems?: {
nodes: MenuItem[];
};
}
export interface Menu {
id: string;
databaseId: number;
name: string;
slug: string;
locations: string[];
menuItems: {
nodes: MenuItem[];
};
}
export type MenuIdentifier =
| { id: number } // По ID меню
| { location: string } // По локации
| { slug: string } // По слагу
| { name: string }; // По имени
/**
* Получить меню по идентификатору
*/
export async function fetchMenu(identifier: MenuIdentifier): Promise