import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'
import ReaderPage from '../views/ReaderPage.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
  },
  {
    path: '/reader',
    name: 'Reader',
    component: ReaderPage,
    props: (route) => ({
      id: route.query.id,
      title: route.query.title,
      extension: route.query.extension,
      targetPage: route.query.page ? parseInt(route.query.page) : null,
      from: route.query.from || '',
    }),
  },
]

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

export default router
