Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3] resolveComponent stopped working when the name of a global component is passed to is prop #2930

Closed
BayBreezy opened this issue Dec 26, 2024 · 3 comments
Labels
question Further information is requested v3

Comments

@BayBreezy
Copy link
Contributor

Environment

  • Operating System: Darwin
  • Node Version: v20.18.1
  • Nuxt Version: 3.15.0
  • CLI Version: 3.17.2
  • Nitro Version: 2.10.4
  • Package Manager: npm@10.8.2
  • Builder: -
  • User Config: default
  • Runtime Modules: @vueuse/nuxt@12.2.0, @nuxtjs/tailwindcss@6.12.2, radix-vue/nuxt, @samk-dev/nuxt-vcalendar@1.0.4, @vee-validate/nuxt@4.15.0, @nuxt/content@3.0.0-alpha.8, @nuxtjs/color-mode@3.5.2, @morev/vue-transitions/nuxt@3.0.5, @nuxt/eslint@0.7.4, nuxt-swiper@2.0.0, v-wave/nuxt, @nuxt/image@1.8.1, @nuxt/icon@1.10.3, @nuxt/fonts@0.10.3, @nuxtjs/seo@2.0.2, @vite-pwa/nuxt@0.10.6
  • Build Modules: -

Reproduction

Not available

Describe the bug

After upgrading to content v3, this syntax no longer works

 <component is="globalComponentName"  />

Additional context

In v2, this worked with mo issues. It stopped working after updating to content v3

Logs

@BayBreezy
Copy link
Contributor Author

For those who find this and want to add functionality for global components like in v2, here you go

  • Add these to the top of the nuxt.config file
import { createResolver } from '@nuxt/kit'

const { resolve } = createResolver(import.meta.url)
  • Add this to modules array
(_, nuxt) => {
      nuxt.hook('components:dirs', (dirs) => {
        dirs.unshift({ path: resolve(PATH_TO_GLOBAL_CONTENT_FOLDER), pathPrefix: false, prefix: '', global: true })
      })
    }

Be sure to replace PATH_TO_GLOBAL_CONTENT_FOLDER with the path: E.g: ./app/components/content

@farnabaz
Copy link
Member

Content v3 does not register components as global. If you want to mark components global, you can either change them to global (like your own solution) or mark an individual component using .global.vue suffix.

@farnabaz farnabaz added question Further information is requested v3 labels Dec 30, 2024
@BayBreezy
Copy link
Contributor Author

That is ok @farnabaz I was under the impression that Nuxt itself marked everything in the content folder as global.
I never knew that it was being done by the module instead. So that is where the confusion was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested v3
Projects
None yet
Development

No branches or pull requests

2 participants