Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue, i18n and vue-meta how to make integration?

Tags:

vuejs2

how to do that when changing the site language, the meta page also changed?

I use vue-i18n - https://kazupon.github.io/vue-i18n/ vue-meta - https://www.npmjs.com/package/vue-meta.

App.vue

export default {
        name: 'Name',
        metaInfo: {
            title: 'Title', // set a title
            titleTemplate: '%s - title', // %s  required
            htmlAttrs: {
                lang: 'ru',
                amp: undefined // "amp" has no value
            },
            meta: [
                {   'name':'og:title',
                    'content': 'title',
                },
                {   'name':'metatitle',
                    'content': 'title',
                },
                {   'name':'og:description',
                    'content': 'Description',
                },
                {   'name':'description',
                    'content': 'Description',
                }

            ]

        },
        data(){return{ }},
        mounted() {}
like image 819
Pavel8289 Avatar asked Oct 17 '25 19:10

Pavel8289


1 Answers

Instead of defining metaInfo as an object, define it as a function and access this as usual.

export default { 
   metaInfo () { 
      return { title: this.$t("home.title") } 
   } 
}

Et voilà ! :)

like image 112
rdhainaut Avatar answered Oct 22 '25 04:10

rdhainaut