index.js 1.7 KB

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