import { ViteSSG } from 'vite-ssg'
import { setupLayouts } from 'virtual:meta-layouts'

import generatedRoutes from 'virtual:generated-pages'
import App from './App.vue'
import type { UserModule } from './types'
import vuetify from './plugins/vuetify'

import '@unocss/reset/tailwind.css'
import './styles/main.css'
import 'uno.css'

// https://github.com/antfu/vite-ssg
export const createApp = ViteSSG(
  App,
  { routes: setupLayouts(generatedRoutes), base: import.meta.env.BASE_URL },
  (ctx) => {
    // install all modules under `modules/`
    Object.values(import.meta.glob<{ install: UserModule }>('./modules/*.ts', { eager: true }))
      .forEach(i => i.install?.(ctx))
    ctx.app.use(vuetify)
  },
)
