vueuse/head

Don't output <link rel="icon"> for the favicon when multiple link tags in <@vueuse/head@0.7.11(?)

mirumirumi opened this issue · 2 comments

(I came here after being asked to open an issue here from an issue opened in nuxt/framework, the issue is this)

Reproduction

https://github.com/mirumirumi/favicon-not-working

Describe the bug

I have been using since about Nuxt@3.0.0-rc-2.

The favicon settings I had written in nuxt.config.ts have been working fine for a long time, but after upgrading from rc8 to rc11, the tags themselves are no longer being output. I have not changed any settings.

However, I noticed that the output is only missing when there are two app.head.link and the favicon tag is defined on the first one. This is very strange, but the following minimum reproduction also reproduces it.

export default defineNuxtConfig({
  app: {
    head: {
      charset: "utf-8",
      meta: [
        // something...
      ],
      link: [
        { rel: "icon", href: "/favicon.ico" },              // <-- this and,
        { rel: "canonical", href: "https://mydomain.me" },  // <-- this. Please reverse the order to be sure.
      ],
    },
  },
})

If the developer has changed the src/ directory, due to the <link rel="icon"> tag not being output, the browser (probably) tries to go to https://mydomain.me/favicon.ico on its own and I get a 404 (I actually use an additional directory called assets under the public directory, so the favicon will be 404).

Any ideas?

Environment

npx nuxi info outputs:

------------------------------
- Operating System: `Linux`
- Node Version:     `v18.9.1`
- Nuxt Version:     `3.0.0-rc.11`
- Nitro Version:    `0.5.4`
- Package Manager:  `npm@8.19.1`
- Builder:          `vite`
- User Config:      `-`
- Runtime Modules:  `-`
- Build Modules:    `-`
------------------------------

Hey @mirumirumi

Thank you for this detailed issue. I have made a PR to resolve it here #105, feel free to review.

Should be merged and released in the next few days

Merged and available in https://github.com/vueuse/head/releases/tag/v0.7.13

Thanks again for the issue and let me know if you have any issues with it