import type { App, Component } from 'vue'

/**
 * Register layouts in the app.go instance
 *
 * @param {App<Element>} app
 */
export function registerLayouts(app: App<Element>) {
  const modules = import.meta.glob<{ default: Component }>('@/layouts/*.vue', {
    eager: true,
  })
  Object.entries(modules).forEach(([key, component]) => {
    const name = key.split('/').slice(-1)[0].replace('.vue', '')
    app.component(name, component.default)
  })
}
