index.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. import Home from 'vuejs/components/Pages/Home'
  4. import Base from 'vuejs/components/Pages/Base'
  5. import Blabla from 'vuejs/components/Pages/Blabla'
  6. import Article from 'vuejs/components/Pages/Article'
  7. import Showrooms from 'vuejs/components/Pages/Showrooms'
  8. Vue.use(VueRouter)
  9. // https://www.lullabot.com/articles/decoupled-hard-problems-routing
  10. // We could use aliases to never reload the page on language changement
  11. // BUT beforeupdate is not triggered when push alias instead of path or name
  12. // const languages = ['en', 'fr'];
  13. // console.log('path aliases', (() => languages.map(l => `/${l}/base`))() );
  14. let basePath = drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix;
  15. const routes = [
  16. {
  17. name: 'home',
  18. path: basePath,
  19. // path: '/',
  20. // alias: (() => languages.map(l => `/${l}`))(),
  21. component: Home
  22. // components: {
  23. // 'home': Home
  24. // }
  25. },
  26. {
  27. name:'base',
  28. path: `${basePath}base`,
  29. // path: `/base`,
  30. // alias: (() => languages.map(l => `/${l}/base`))(),
  31. component: Base,
  32. // components: {
  33. // 'base': Base
  34. // }
  35. },
  36. // {
  37. // name:'blabla',
  38. // path: `${basePath}blabla`,
  39. // component: Blabla,
  40. // children: [
  41. // {
  42. // path: `${basePath}blabla/:alias`,
  43. // component: Article
  44. // }
  45. // ]
  46. // }
  47. {
  48. name:'blabla',
  49. path: `${basePath}blabla`,
  50. component: Blabla
  51. },
  52. {
  53. name:'article',
  54. path: `${basePath}blabla/:alias`,
  55. component: Article,
  56. // meta: { uuid:null }
  57. },
  58. {
  59. name:'showrooms',
  60. path: `${basePath}showrooms`,
  61. component: Showrooms,
  62. // meta: { uuid:null }
  63. }
  64. // {
  65. // path: '*',
  66. // name: 'notfound',
  67. // components: {
  68. // 'notfound': NotFound
  69. // }
  70. // }
  71. ]
  72. export default new VueRouter({
  73. mode: 'history',
  74. routes: routes
  75. })