vueuse/head

Deduping from initial head not working

Closed this issue · 4 comments

Hello,

I have looked through previous issues and was able to find the following two posts:

However, unless I am missing something extremely obvious, the support for 'Vue Meta keys' doesn't appear to work.

I have my initial HTML that includes the following two tags (example):

<meta property="og:title" data-key="og:title" content="Hello World" />
<meta property="twitter:title" data-key="twitter:title" content="Hello World" />

I am trying to update the contents of these tags like so:

useHead({
    meta: [
        { name: 'og:title', key: 'og:title', content: title },
        { name: 'twitter:title', key: 'twitter:title', content: title }
    ]
});

Instead of the tags being updated, new (duplicate) tags are being appended to the head.

I have tried various things;

  • removing the data- portion of the attribute
  • trying both vmid and hid
  • using a key without special characters i.e. data-key="test"

None of the above have worked. Have I missed something in the documentation or is this not expected to work in this way?

I am aware that I could implement a fix similar to this one but I consider that to be pretty dirty and would only like to resort to that if absolutely necessary.

Thanks in advance for any assistance!

Unhead should automatically dedupe your initial tags, just remove the key property.

You should keep the prop keys the same though:

  • og:title - property
  • twitter:title - name

As expected, it was a stupid mistake from my end - as you pointed out, I was using the wrong keys. Thank you so much, and sorry for the inconvenience.

Not at all @sinemacula-ben, glad you could solve the problem :) Appreciate the research you did on the issue

Why doesn't using a key work in this case, though? I'm trying to figure out if it's related to: unjs/unhead#145