import Vue from 'vue';
import Router from 'vue-router';

import Index from '@/views/_id.vue';
import Found from '@/views/_.vue';

Vue.use(Router);

export function createRouter(ssrContext) {
  if (ssrContext && ssrContext.url) {
    ssrContext.url = ssrContext.url.replace(/%(?![0-9A-F]{2})/g, '%25');
  }
  return new Router({
    mode: 'history',
    base: process.env.baseUrl,
    routes: [
      {
        path: '/:id',
        name: 'index-id',
        component: Index
      },
      {
        path: '*',
        name: '404',
        component: Found
      }
    ]
  });
}
