index.js 1.4 KB

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