updating language switcher links on route change; fixed prev/next blabla article links

This commit is contained in:
Bachir Soussi Chiadmi 2021-01-27 21:21:20 +01:00
parent 2b67b22ce5
commit 584c4cc5d2
3 changed files with 22 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -103,7 +103,6 @@ Vue.use(VueSimpleAccordion, {
function initVi18n () {
// i18n.locale = drupalDecoupled.lang_code
// console.log('i18n.messages', i18n.messages)
loadLanguageAsync(drupalDecoupled.lang_code)
.then(() => {
console.log('main.js language loaded')
@ -164,6 +163,22 @@ Vue.use(VueSimpleAccordion, {
}
document.querySelector('body').classList.add(...classes)
// update block language selection
let links = document.querySelectorAll('#block-languageswitcher a.language-link')
let path = to.path.replace(/^\/\D{2,3}\//, '')
// remove language relative prefix from path classes (fr, en, etc)
.replace(/^\/\D{2,3}$/, '')
if(path !== ''){
path = '/'+path
}
links.forEach((link, i) => {
console.log("language link",path , link)
link.setAttribute('href', `/${link.getAttribute('hreflang')}${path}`)
});
// trigger router
next()
})

View File

@ -295,8 +295,10 @@ export default {
this.loading = false;
},
onPrevNext(a){
// console.log('clicked on next', this.prevnext.next);
let alias = a.replace(/^.?\/blabla\//g, '')
console.log('clicked on prev/next; a', a);
let alias = a.replace(/^\/\D{2,3}\/blabla\//g, '')
console.log('alias', alias);
this.$router.push({
name:`article`,
params: { alias:alias }