Sfoglia il codice sorgente

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

bach 3 anni fa
parent
commit
584c4cc5d2

File diff suppressed because it is too large
+ 0 - 0
web/themes/custom/materiotheme/assets/dist/main.js


+ 16 - 1
web/themes/custom/materiotheme/assets/scripts/main.js

@@ -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()
       })

+ 4 - 2
web/themes/custom/materiotheme/vuejs/components/Pages/Article.vue

@@ -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 }

Some files were not shown because too many files changed in this diff