UNPKG

@adonisjs/inertia

Version:

Official Inertia.js adapter for AdonisJS

28 lines (27 loc) 1.23 kB
/** * Resolves a page component from a given path or array of paths by looking up * the component in the provided pages registry. Supports both direct promises * and lazy-loaded functions that return promises. * * @param path - The page path(s) to resolve. Can be a single string or array of strings * @param pages - Registry of page components where keys are paths and values are either promises or functions returning promises * @param layout - Optional layout component to assign to the resolved page * @returns Promise resolving to the page component * * @example * ```js * // Single path resolution * const component = await resolvePageComponent('Home', { * 'Home': () => import('./pages/Home.vue'), * 'About': () => import('./pages/About.vue') * }) * * // Multiple path resolution (fallback) * const component = await resolvePageComponent(['Dashboard/Admin', 'Dashboard'], { * 'Dashboard': () => import('./pages/Dashboard.vue') * }) * ``` * * @throws Error When none of the provided paths can be resolved in the pages registry */ export declare function resolvePageComponent<T>(path: string | string[], pages: Record<string, Promise<T> | (() => Promise<T>) | T>, layout?: any): Promise<T>;