docs: add addComponentsDir example to modules author guide (#24876)

This commit is contained in:
Isaac Qadri 2023-12-23 17:22:13 +03:00 committed by GitHub
parent 4dcc48f4e6
commit 14b95e0d4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -335,6 +335,22 @@ export default defineNuxtModule({
})
```
Alternatively, you can add an entire directory by using `addComponentsDir`.
```ts
import { defineNuxtModule, addComponentsDir } from '@nuxt/kit'
export default defineNuxtModule({
setup(options, nuxt) {
const resolver = createResolver(import.meta.url)
addComponentsDir({
path: resolver.resolve('runtime/components')
})
}
})
```
#### Injecting Composables With `addImports` and `addImportsDir`
If your module should provide composables, you can use the `addImports` utility to add them as auto-imports for Nuxt to resolve.