vue-meta icon indicating copy to clipboard operation
vue-meta copied to clipboard

Vue meta Alpha8 doens't generate meta tags properly

Open AsoStrife opened this issue 2 years ago • 9 comments

Hi I'm using Vue3 with vue-meta: ^3.0.0-alpha.8. I'm trying to setup my project in order to set dynamically the meta-tags. Here my code on App.vue:

import constants from './constants'

export default {
   data() {
      return {
         constants: constants
         }
      }
   },
   setup() {
      useMeta({
         htmlAttrs: { 
            lang: constants.meta.language,
         },
         description: constants.main.description,
         meta: [
            {
               name: 'author',
               content: constants.meta.author
            },
            {
               name: 'keywords',
               content: constants.meta.keywords
            },
            {
               name: 'robots',
               content: constants.meta.robots
            }
          ]
      }
   }
}

htmlAttrs and description works fine generating: <html lang="en" ... and <meta name="description" content="My description">

The other tags, on the other hand, are generated incorrectly:

<meta name="meta" content="my author string">
<meta name="meta" content="my keywords string">
<meta name="meta" content="my robots string">

Why it is generating <meta name="meta" .. instead of <meta name="MY PARAMETER NAME" ..?

AsoStrife avatar Mar 23 '22 08:03 AsoStrife

Having the same issue, using the property as name works through.

wesly1988 avatar Mar 24 '22 06:03 wesly1988

Having the same issue

numver avatar Mar 29 '22 05:03 numver

Having the same issue, using the property as name works through.

What do you mean with: using the property as name works through?

AsoStrife avatar Mar 29 '22 07:03 AsoStrife

3.0.0-alpha.10 has same issue

DayDarkDark avatar Mar 31 '22 03:03 DayDarkDark

Same issue.

Lasim avatar Apr 05 '22 16:04 Lasim

Having the same issue, using the property as name works through.

What do you mean with: using the property as name works through?

property="name" seems to work fine

wesly1988 avatar Apr 13 '22 05:04 wesly1988

Having the same issue. Has anyone found a solution? I am using the alpha.10 version.

sorakylin avatar Apr 20 '22 01:04 sorakylin

I found a method that works, although it seems odd.

//import
import {createMetaManager, defaultConfig} from 'vue-meta'

//createApp setting
const metaManager = createMetaManager(!!import.meta.env.SSR, {
    ...defaultConfig,
    ...{
        'applicable-device': {
            tag: 'meta',
            keyAttribute: 'name',
            valueAttribute: 'content'
        },
    }
})

app.use(metaManager);

// use
useMeta({
    'applicable-device': "pc",
})

result >>> <meta name="applicable-device" content="pc">

sorakylin avatar Apr 20 '22 01:04 sorakylin

Well some how this will fix the issue. I think it overwrites it. meta: [{ name: 'robots', Name: 'robots', content: 'noindex,nofollow' }],

drcodemonster avatar Oct 11 '22 09:10 drcodemonster