kevinmarrec / nuxt-pwa-module

⚠️ DEPRECATED ⚠️ Zero config PWA solution for Nuxt 3
MIT License
338 stars 32 forks source link

Manifest default 'theme_color' gets injected as duplicate meta 'theme-color' #53

Closed toniengelhardt closed 1 year ago

toniengelhardt commented 1 year ago

The default for theme_color in the manifest is set to #000000. This gets somehow injected as a duplicate theme-color meta tag in the header and overrides the normal theme-color from meta. You can see this, when adding this in nuxt.config.ts:

app: {
  head: {
    meta: [
      { name: 'theme-color', content: '#FFFFFF' },
    }
  }
}

and opening the app in Chrome mobile. The theme will be black.

Here's the HTML output:

Screen Shot 2022-10-18 at 12 37 46

A note on setting meta tags automatically from manifest... I think that is not a good idea at all, or at least they should not override existing meta tags because the meta tags can be controlled dynamically in the code whereas manifest can not.

In my app for instance, I want to set the theme-color dynamically from the theme the app uses, which works perfectly if they are set and updated as meta tags in Nuxt 2.

Demo: https://pwa.journalisticapp.com

kevinmarrec commented 1 year ago

@toniengelhardt Well if there's no automatic meta tags, if user does not set it dynamically in their code, it would miss many required tags for PWA. I'd vote for the possibility to opt-out each automatic meta tag, to prevent any duplicated tag and have full control.

I think we should be able to pass false to any property under pwa.meta.

It's already the case for many properties (one example is mobileApp property), but for theme_color, it fallback to pwa.manifest value, and as of its TypeScript type, boolean is not accepted.

Here are the current types for each property : https://github.com/kevinmarrec/nuxt-pwa-module/blob/bdd4b4fbb4c78d804e36847b9510a535d393a4c0/src/parts/meta/types.ts#L1-L21

I should enhance them to make them all able to be either boolean | {currentType} or just false | {currentType}.

toniengelhardt commented 1 year ago

Sounds good!