@nuxt/docs-nightly 4.0.0-29159138.a14e790d → 4.0.0-29159317.1927782f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/3.api/5.kit/11.nitro.md
CHANGED
|
@@ -293,6 +293,53 @@ function addPrerenderRoutes (routes: string | string[]): void
|
|
|
293
293
|
| ----------- | ------------------------------- | -------- | ---------------------------------------------- |
|
|
294
294
|
| `routes` | `string \| string[]`{lang="ts"} | `true` | A route or an array of routes to prerender. |
|
|
295
295
|
|
|
296
|
+
## `addServerImports`
|
|
297
|
+
|
|
298
|
+
Add imports to the server. It makes your imports available in Nitro without the need to import them manually.
|
|
299
|
+
|
|
300
|
+
### Usage
|
|
301
|
+
|
|
302
|
+
```ts twoslash
|
|
303
|
+
import { defineNuxtModule, createResolver, addServerImports } from '@nuxt/kit'
|
|
304
|
+
|
|
305
|
+
export default defineNuxtModule({
|
|
306
|
+
setup(options) {
|
|
307
|
+
const names = [
|
|
308
|
+
'useStoryblok',
|
|
309
|
+
'useStoryblokApi',
|
|
310
|
+
'useStoryblokBridge',
|
|
311
|
+
'renderRichText',
|
|
312
|
+
'RichTextSchema'
|
|
313
|
+
]
|
|
314
|
+
|
|
315
|
+
names.forEach((name) =>
|
|
316
|
+
addServerImports({ name, as: name, from: '@storyblok/vue' })
|
|
317
|
+
)
|
|
318
|
+
}
|
|
319
|
+
})
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Type
|
|
323
|
+
|
|
324
|
+
```ts
|
|
325
|
+
function addServerImports (dirs: Import | Import[]): void
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Parameters
|
|
329
|
+
|
|
330
|
+
`imports`: An object or an array of objects with the following properties:
|
|
331
|
+
|
|
332
|
+
| Property | Type | Required | Description |
|
|
333
|
+
| ------------------ | ---------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
|
|
334
|
+
| `name` | `string` | `true` | Import name to be detected. |
|
|
335
|
+
| `from` | `string` | `true` | Module specifier to import from. |
|
|
336
|
+
| `priority` | `number` | `false` | Priority of the import; if multiple imports have the same name, the one with the highest priority will be used. |
|
|
337
|
+
| `disabled` | `boolean` | `false` | If this import is disabled. |
|
|
338
|
+
| `meta` | `Record<string, any>` | `false` | Metadata of the import. |
|
|
339
|
+
| `type` | `boolean` | `false` | If this import is a pure type import. |
|
|
340
|
+
| `typeFrom` | `string` | `false` | Use this as the `from` value when generating type declarations. |
|
|
341
|
+
| `as` | `string` | `false` | Import as this name. |
|
|
342
|
+
|
|
296
343
|
## `addServerImportsDir`
|
|
297
344
|
|
|
298
345
|
Add a directory to be scanned for auto-imports by Nitro.
|
|
@@ -34,16 +34,16 @@ import { defineNuxtModule, addImports } from "@nuxt/kit";
|
|
|
34
34
|
export default defineNuxtModule({
|
|
35
35
|
setup(options, nuxt) {
|
|
36
36
|
const names = [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
]
|
|
37
|
+
'useStoryblok',
|
|
38
|
+
'useStoryblokApi',
|
|
39
|
+
'useStoryblokBridge',
|
|
40
|
+
'renderRichText',
|
|
41
|
+
'RichTextSchema'
|
|
42
|
+
]
|
|
43
43
|
|
|
44
44
|
names.forEach((name) =>
|
|
45
|
-
addImports({ name, as: name, from:
|
|
46
|
-
)
|
|
45
|
+
addImports({ name, as: name, from: '@storyblok/vue' })
|
|
46
|
+
)
|
|
47
47
|
}
|
|
48
48
|
})
|
|
49
49
|
```
|