import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import PageView from '@/views/PageView.vue'
import type { Page } from '@/types/page'

const addPages = [] as Array<Page>


export function loadDynamicPages(pages:Array<Page>){

  for (const page of addPages){
    router.removeRoute(page.Title!)
  }
  for (const page of pages){
    addPages.push(page)
    router.addRoute({path: page.path, name: page.Title, sensitive: false, component: PageView})

  }
}

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
    }
  ],
})


export default router
