export async function resolvePageComponent(name: string, pages: Record, defaultLayout?: any) { const mapped: string[] = [] const path = Object.keys(pages) .sort((a, b) => a.length - b.length) .find((path) => { mapped.push( path = path .replace('../domains/', '') .replace('/pages/', '/') .replace('.vue', '') .replace('/', '.'), ) return path === name }) if (!path) { throw new Error(`Page component "${name}" could not be found. Available pages: \n- ${mapped.join('\n- ')}`) } let component = typeof pages[path] === 'function' ? await pages[path]() : pages[path] component = component.default ?? component component.layout ??= defaultLayout return component }