nuxt-community/gtm-module

Module initialization breaks "head" functionality on purpose

gekkedev opened this issue · 3 comments

Issue

It caused me quite a headache and cost me a lot of time, but the way that this module breaks Nuxt's head functionality should be addressed urgently. It resets settings intentionally:

this.options.head = {}

Indeed, there is a warning:
console.warn('[@nuxtjs/gtm] head is provided as a function which is not supported by this module at the moment. Removing user-provided head.')

But: Not everybody checks their server console when the browser console output is pretty accurate every time; and some people are even slowed down on checking the server console due to corporate access restrictions, or only use static builds and never see an error, they only see the program misbehaving...let's not talk about use-cases, there are plenty.

To reproduce:

I've simply installed both @nuxtjs/gtm and the module @nuxtjs/i18n and enabled SEO attribute generation (a pretty common functionality to enable) according to the manual. It doesn't have to be this module, it breaks as soon as you want a bit of dynamic code to fill your head setting (using a function instead of an object).

I'm trying some stuff to fix this, but until there is an official bugfix, any workaround would be decent.

zipme commented

This also happens when we use @nuxtjs/composition-api's useMeta

@gekkedev I think I've found the solution. I've replaced the head() function inside nuxt.config.js by a head object with only the static tags. And I've moved all the dynamic ones (especially i18n) to a head() function inside the layouts/default.vue file.

Any update for this? I think a lot of people use nuxt with i18n