import { createRouter, createWebHashHistory } from 'vue-router';

const pages = import.meta.glob('../views/**/*.vue');

const routes = Object.keys(pages).map((path) => {
  const routePath = path
    .replace(/..\/views/, '')
    .replace(/\.\w+$/, '')
    .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
    .toLowerCase()
    .replace(/index$/, '');

  return {
    path: routePath,
    component: pages[path],
  };
});

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
