Skip to content
This repository has been archived by the owner on Dec 5, 2021. It is now read-only.

Duplicate lang, language, charset meta tags when target:static #96

Open
abernh opened this issue Mar 9, 2021 · 1 comment
Open

Duplicate lang, language, charset meta tags when target:static #96

abernh opened this issue Mar 9, 2021 · 1 comment

Comments

@abernh
Copy link
Contributor

abernh commented Mar 9, 2021

When using with target:static multiple meta tags are duplicated in my generated html files.
E.g. lang, charset, language, viewport, ... all meta tags, that modules.js are handled during generate() as "without content"

Investigating the issue I found, that this is a "problem" with vue-meta.
when vue-meta is refreshing the metas it removes duplicates only based on the given hid
If there is no hid set, then it is possible, that a single meta value is added multiple times.

Proposed fix

Adding hid based on meta.id when generating the metas so that vue-metas filtering works as expected.

//modules.js:241
  const generate = (metas, optionsGenerate, id = '', index = false) => {
      ...

      if (meta.value && meta.multi && Array.isArray(meta.value)) {
        ...
      } else if (typeof meta.value === 'object' && !Array.isArray(meta.value)) {
        ...
      } else if (meta.content) {
        ...
      } else if (meta.id) {
        if (meta.ids) {
          meta.ids.map(id => {
            ...

            outputMeta.push({
              hid: id, // -------------------> add hid
              [id]: meta.value
            })
          })
        } else {
          ...     

          outputMeta.push({
            hid: meta.id, //  -------------------> add hid
            [meta.id]: meta.value
          })
        }
      }
    })
  }

I'll prepare a PR

abernh added a commit to abernh/Nuxt-SEO that referenced this issue Mar 9, 2021
also extend all route-tests to count number of occurrences for no-content meta tags, e.g. `charset`

rel: TiagoDanin#96
abernh added a commit to abernh/Nuxt-SEO that referenced this issue Mar 9, 2021
also update `test/fixtures/all.js` accordingly

rel: TiagoDanin#96
@abernh abernh changed the title Duplicate lang, language, charset meta tags Duplicate lang, language, charset meta tags when target:static Mar 9, 2021
@TiagoDanin
Copy link
Owner

#109

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

No branches or pull requests

2 participants