import Vue from 'vue'
import Root from './Root.vue'
import App from './App.vue'
import About from './components/About.vue'
import DictionaryView from './components/DictionaryView.vue'
import VueRouter from 'vue-router'
import { VuePlausible } from 'vue-plausible'
import vuetify from './plugins/vuetify'


Vue.config.productionTip = false
Vue.use(VueRouter)
Vue.use(VuePlausible, {
  domain: 'beta.ordbok.uib.no'
})

Vue.$plausible.enableAutoPageviews()

const router = new VueRouter({
  mode: 'history',
  base: __dirname,
  routes: [
    {
      path: '/',
      component: App,
      children: [
        {
          path: 'om',
          name: 'about',
          component: About
        },
        {
          path: '',
          component: DictionaryView,
          children: [
            {
              path: ':lang(bm|nn|bm,nn)',
              children: [
                {
                  name: 'word',
                  path: 'w/:word/:pos?'
                },
                {
                  name: 'lookup',
                  path: ':id(\\d+)/:lemma?'
                },
                {
                  name: 'search',
                  path: 'search/:query'
                }
              ]
            },
            {
              path: 'bob/*',
              redirect: to => {
                return "bm/" + to.params.pathMatch
              }
            },
            {
              path: 'nob/*',
              redirect: to => {
                console.log(to)
                return "nn/" + to.params.pathMatch
              }
            },
            {
              path: 'bob,nob/*',
              redirect: to => {
                return "bm,nn/" + to.params.pathMatch
              }
            }
          ]
        }
      ]
    }
  ]
})

new Vue({
  router,
  vuetify,
  render: h => h(Root )
}).$mount('#app')