updating language switcher links on route change; fixed prev/next blabla article links
This commit is contained in:
		
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -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() | ||||
|       }) | ||||
|   | ||||
| @@ -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 } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user