index.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. import Home from 'vuejs/components/Content/Home'
  4. import Base from 'vuejs/components/Content/Base'
  5. Vue.use(VueRouter)
  6. // https://www.lullabot.com/articles/decoupled-hard-problems-routing
  7. // We could use aliases to never reload the page on language changement
  8. // BUT beforeupdate is not triggered when push alias instead of path or name
  9. const languages = ['en', 'fr'];
  10. console.log('path aliases', (() => languages.map(l => `/${l}/base`))() );
  11. let basePath = drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix;
  12. const routes = [
  13. {
  14. name: 'home',
  15. path: basePath,
  16. // path: '/',
  17. // alias: (() => languages.map(l => `/${l}`))(),
  18. component: Home
  19. // components: {
  20. // 'home': Home
  21. // }
  22. },
  23. {
  24. name:'base',
  25. path: `${basePath}base`,
  26. // path: `/base`,
  27. // alias: (() => languages.map(l => `/${l}/base`))(),
  28. component: Base,
  29. // components: {
  30. // 'base': Base
  31. // }
  32. },
  33. // {
  34. // path: '*',
  35. // name: 'notfound',
  36. // components: {
  37. // 'notfound': NotFound
  38. // }
  39. // }
  40. ]
  41. export default new VueRouter({
  42. mode: 'history',
  43. routes: routes
  44. })