2019-06-03 13:06:44 +02:00
|
|
|
import Vue from 'vue'
|
|
|
|
import VueRouter from 'vue-router'
|
|
|
|
|
|
|
|
import Home from 'vuejs/components/Content/Home'
|
|
|
|
import Base from 'vuejs/components/Content/Base'
|
2019-07-12 22:15:09 +02:00
|
|
|
import Blabla from 'vuejs/components/Content/Blabla'
|
2019-07-14 15:21:04 +02:00
|
|
|
import Article from 'vuejs/components/Content/Article'
|
2019-06-03 13:06:44 +02:00
|
|
|
|
|
|
|
Vue.use(VueRouter)
|
|
|
|
|
2019-06-04 22:38:44 +02:00
|
|
|
// https://www.lullabot.com/articles/decoupled-hard-problems-routing
|
|
|
|
|
2019-06-06 17:37:43 +02:00
|
|
|
// We could use aliases to never reload the page on language changement
|
|
|
|
// BUT beforeupdate is not triggered when push alias instead of path or name
|
2019-07-14 15:21:04 +02:00
|
|
|
// const languages = ['en', 'fr'];
|
|
|
|
// console.log('path aliases', (() => languages.map(l => `/${l}/base`))() );
|
2019-06-06 17:37:43 +02:00
|
|
|
|
|
|
|
let basePath = drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix;
|
|
|
|
|
|
|
|
const routes = [
|
|
|
|
{
|
|
|
|
name: 'home',
|
|
|
|
path: basePath,
|
|
|
|
// path: '/',
|
|
|
|
// alias: (() => languages.map(l => `/${l}`))(),
|
|
|
|
component: Home
|
|
|
|
// components: {
|
|
|
|
// 'home': Home
|
|
|
|
// }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name:'base',
|
|
|
|
path: `${basePath}base`,
|
|
|
|
// path: `/base`,
|
|
|
|
// alias: (() => languages.map(l => `/${l}/base`))(),
|
|
|
|
component: Base,
|
|
|
|
// components: {
|
|
|
|
// 'base': Base
|
|
|
|
// }
|
|
|
|
},
|
2019-07-14 15:21:04 +02:00
|
|
|
// {
|
|
|
|
// name:'blabla',
|
|
|
|
// path: `${basePath}blabla`,
|
|
|
|
// component: Blabla,
|
|
|
|
// children: [
|
|
|
|
// {
|
|
|
|
// path: `${basePath}blabla/:alias`,
|
|
|
|
// component: Article
|
|
|
|
// }
|
|
|
|
// ]
|
|
|
|
// }
|
2019-07-12 22:15:09 +02:00
|
|
|
{
|
|
|
|
name:'blabla',
|
|
|
|
path: `${basePath}blabla`,
|
2019-07-14 15:21:04 +02:00
|
|
|
component: Blabla
|
2019-07-12 22:15:09 +02:00
|
|
|
},
|
2019-07-14 15:21:04 +02:00
|
|
|
{
|
|
|
|
name:'article',
|
|
|
|
path: `${basePath}blabla/:alias`,
|
|
|
|
component: Article,
|
|
|
|
// meta: { uuid:null }
|
|
|
|
}
|
2019-06-06 17:37:43 +02:00
|
|
|
// {
|
|
|
|
// path: '*',
|
|
|
|
// name: 'notfound',
|
|
|
|
// components: {
|
|
|
|
// 'notfound': NotFound
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
]
|
|
|
|
|
2019-06-03 13:06:44 +02:00
|
|
|
export default new VueRouter({
|
2019-06-04 22:38:44 +02:00
|
|
|
mode: 'history',
|
2019-06-06 17:37:43 +02:00
|
|
|
routes: routes
|
2019-06-03 13:06:44 +02:00
|
|
|
})
|