|
@@ -53,6 +53,8 @@ Vue.use(VueSimpleAccordion, {
|
|
|
// ... Options go here
|
|
|
});
|
|
|
|
|
|
+import { MA } from 'vuejs/api/ma-axios'
|
|
|
+
|
|
|
(function (Drupal, drupalSettings, drupalDecoupled) {
|
|
|
const MaterioTheme = function () {
|
|
|
let _v_sitebranding_block, _v_user_block, _v_header_menu,
|
|
@@ -163,25 +165,36 @@ 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}$/, '')
|
|
|
+ updateLanguageLinksBlock(to.path);
|
|
|
+ // trigger router
|
|
|
+ next()
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
- if(path !== ''){
|
|
|
- path = '/'+path
|
|
|
- }
|
|
|
+ function updateLanguageLinksBlock(path){
|
|
|
+ // update block language selection
|
|
|
+ console.log("updateLanguageLinksBlock, path:", path);
|
|
|
+ let links = document.querySelectorAll('#block-languageswitcher a.language-link')
|
|
|
|
|
|
- links.forEach((link, i) => {
|
|
|
- console.log("language link",path , link)
|
|
|
- link.setAttribute('href', `/${link.getAttribute('hreflang')}${path}`)
|
|
|
- });
|
|
|
+ let params = {
|
|
|
+ path: path
|
|
|
+ // XDEBUG_SESSION_START: true
|
|
|
+ }
|
|
|
|
|
|
+ MA.post(`materio_decoupled/path_translation_links?`, params)
|
|
|
+ .then(({ data }) => {
|
|
|
+ console.log('Path translations links', data)
|
|
|
+ links.forEach((link, i) => {
|
|
|
+ console.log("language link",path , link)
|
|
|
+ let hreflang = link.getAttribute('hreflang')
|
|
|
|
|
|
- // trigger router
|
|
|
- next()
|
|
|
- })
|
|
|
+ link.setAttribute('href', data.links[hreflang].url)
|
|
|
+ link.innerHTML = data.links[hreflang].title
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.warn('Path translations links', error)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
function initVSiteBrandingBlock () {
|