N
Nuxt5mo ago
vinum?

Nuxt layer component prefix

How do i make a prefix like Nuxt UI Pro has? Nuxt UI Pro has the U prefix and i would like that for my components too (Instead of "U" i want my layer to use "VD". I can't seem to get it to work
1 Reply
Vida
Vida5mo ago
If you want all components in that layer to be prefixed with 'VD' then you would do something like this in your nuxt config:
export default defineNuxtConfig({
components: [ { path: "@/path_to_your_layer/components/", prefix: "VD", pathPrefix: false }]
})
export default defineNuxtConfig({
components: [ { path: "@/path_to_your_layer/components/", prefix: "VD", pathPrefix: false }]
})
With this you can put any components inside the layers components folder and when using those components you have to prefix them with VD. Notice the 'pathPrefix: false' is optional, the default behaviour being true. If its false you can structure your folders in any way you want inside that layer. If you want to structure them the default way you remove that option. Another example would be :
export default defineNuxtConfig({
components: [{ path: "@/path_to_your_layer/components/" }, { path: "@/path_to_your_layer/components/vd_components", prefix: "VD", pathPrefix: false }]
})
export default defineNuxtConfig({
components: [{ path: "@/path_to_your_layer/components/" }, { path: "@/path_to_your_layer/components/vd_components", prefix: "VD", pathPrefix: false }]
})
This way we can have prefixed only the components we have in vd_components and the components folder behaves defaultly. Hope it helps
Want results from more Discord servers?
Add your server