Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useNuxt2Meta values didn't update if values are computed #466

Open
antlionguard opened this issue Aug 5, 2022 · 1 comment
Open

useNuxt2Meta values didn't update if values are computed #466

antlionguard opened this issue Aug 5, 2022 · 1 comment

Comments

@antlionguard
Copy link

antlionguard commented Aug 5, 2022

Environment



Reproduction

https://codesandbox.io/s/dreamy-maxwell-ir8qu1?file=/pages/index.vue

Describe the bug

Meta object values are not updating if object values (title, link, meta etc.) are computed.

Additional context

I cannot see browser title on codesandbox. Therefore i downloaded reproduction into my computer and i tested in locally.

Logs

No response

@antlionguard antlionguard changed the title useNuxt2Meta values didn't update if value is computed useNuxt2Meta values didn't update if values are computed Aug 5, 2022
@oppianmatt
Copy link

we have this problem as well, very annoying. We found that if the head was already created before you call useNuxt2Meta it works. But if you try call useNuxt2Meta say in onServerPrefetch it doesn't work as needs a nuxt instance. So we created a component whose job is to call useNuxt2Meta and instantiate that when your head is ready from the parent. For example:

<template>
  <client-only />
</template>

<script setup lang="ts">
import { useNuxt2Meta } from '#imports'
import { PropType } from 'vue'

const props = defineProps({
  nuxt2meta: {
    type: Object as PropType<Parameters<typeof useNuxt2Meta>[0]>,
    required: true
  }
})

useNuxt2Meta(props.nuxt2meta)
</script>

then in the parent you do this:

    <nuxt-to-meta
      v-if="title"
      :nuxt2meta="headData"
    />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants