router.options.ts 549 B

123456789101112131415161718
  1. import type { RouterConfig } from '@nuxt/schema'
  2. import routes from '@/app/pages/routes'
  3. const addonRoutes = import.meta.globEager('@/addon/**/pages/routes.ts')
  4. for (const key in addonRoutes) {
  5. const addon = key.split('/')[2]
  6. routes.push(...addonRoutes[key].default.map((item) => {
  7. item.meta = item.meta ? Object.assign(item.meta, { addon }) : { addon }
  8. return item
  9. }))
  10. }
  11. // https://router.vuejs.org/api/interfaces/routeroptions.html
  12. export default <RouterConfig>{
  13. routes: (_routes) => routes,
  14. strict: false
  15. }