@nuxt/docs-nightly 4.1.3-29313386.edc02e27 → 4.1.3-29316215.910d159d
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/1.getting-started/01.introduction.md +4 -4
- package/1.getting-started/02.installation.md +1 -1
- package/1.getting-started/03.configuration.md +25 -25
- package/1.getting-started/04.views.md +3 -3
- package/1.getting-started/05.assets.md +9 -3
- package/1.getting-started/06.styling.md +53 -43
- package/1.getting-started/07.routing.md +9 -9
- package/1.getting-started/08.seo-meta.md +50 -37
- package/1.getting-started/09.transitions.md +38 -33
- package/1.getting-started/10.data-fetching.md +61 -53
- package/1.getting-started/11.state-management.md +19 -12
- package/1.getting-started/12.error-handling.md +17 -15
- package/1.getting-started/13.server.md +8 -8
- package/1.getting-started/14.layers.md +19 -13
- package/1.getting-started/15.prerendering.md +28 -28
- package/1.getting-started/16.deployment.md +8 -8
- package/1.getting-started/17.testing.md +42 -42
- package/1.getting-started/18.upgrade.md +50 -68
- package/2.guide/0.index.md +5 -5
- package/2.guide/1.directory-structure/0.output.md +1 -1
- package/2.guide/1.directory-structure/1.app/1.assets.md +1 -1
- package/2.guide/1.directory-structure/1.app/1.components.md +40 -23
- package/2.guide/1.directory-structure/1.app/1.composables.md +9 -9
- package/2.guide/1.directory-structure/1.app/1.layouts.md +12 -8
- package/2.guide/1.directory-structure/1.app/1.middleware.md +23 -17
- package/2.guide/1.directory-structure/1.app/1.pages.md +25 -23
- package/2.guide/1.directory-structure/1.app/1.plugins.md +17 -17
- package/2.guide/1.directory-structure/1.app/1.utils.md +3 -3
- package/2.guide/1.directory-structure/1.app/3.app-config.md +7 -7
- package/2.guide/1.directory-structure/1.app/3.app.md +3 -3
- package/2.guide/1.directory-structure/1.app/3.error.md +4 -4
- package/2.guide/1.directory-structure/1.content.md +4 -1
- package/2.guide/1.directory-structure/1.modules.md +5 -5
- package/2.guide/1.directory-structure/1.public.md +1 -1
- package/2.guide/1.directory-structure/1.server.md +30 -30
- package/2.guide/1.directory-structure/1.shared.md +3 -3
- package/2.guide/1.directory-structure/2.env.md +3 -3
- package/2.guide/1.directory-structure/2.nuxtrc.md +1 -1
- package/2.guide/1.directory-structure/3.nuxt-config.md +1 -1
- package/2.guide/2.concepts/1.auto-imports.md +15 -15
- package/2.guide/2.concepts/10.nuxt-lifecycle.md +7 -7
- package/2.guide/2.concepts/2.vuejs-development.md +9 -9
- package/2.guide/2.concepts/3.rendering.md +17 -15
- package/2.guide/2.concepts/4.server-engine.md +1 -1
- package/2.guide/2.concepts/5.modules.md +3 -3
- package/2.guide/2.concepts/7.esm.md +16 -14
- package/2.guide/2.concepts/8.typescript.md +4 -4
- package/2.guide/3.going-further/1.events.md +3 -3
- package/2.guide/3.going-further/1.experimental-features.md +238 -77
- package/2.guide/3.going-further/1.features.md +44 -9
- package/2.guide/3.going-further/1.internals.md +15 -15
- package/2.guide/3.going-further/10.runtime-config.md +8 -8
- package/2.guide/3.going-further/11.nightly-release-channel.md +1 -1
- package/2.guide/3.going-further/2.hooks.md +11 -11
- package/2.guide/3.going-further/3.modules.md +83 -81
- package/2.guide/3.going-further/4.kit.md +5 -5
- package/2.guide/3.going-further/6.nuxt-app.md +4 -4
- package/2.guide/3.going-further/7.layers.md +51 -42
- package/2.guide/3.going-further/9.debugging.md +2 -2
- package/2.guide/4.recipes/1.custom-routing.md +19 -19
- package/2.guide/4.recipes/2.vite-plugin.md +3 -3
- package/2.guide/4.recipes/3.custom-usefetch.md +10 -10
- package/2.guide/4.recipes/4.sessions-and-authentication.md +34 -20
- package/2.guide/5.best-practices/performance.md +13 -13
- package/3.api/1.components/1.client-only.md +6 -3
- package/3.api/1.components/1.nuxt-client-fallback.md +10 -7
- package/3.api/1.components/11.teleports.md +5 -2
- package/3.api/1.components/12.nuxt-route-announcer.md +7 -7
- package/3.api/1.components/13.nuxt-time.md +44 -17
- package/3.api/1.components/2.nuxt-page.md +4 -4
- package/3.api/1.components/3.nuxt-layout.md +13 -8
- package/3.api/1.components/4.nuxt-link.md +40 -20
- package/3.api/1.components/5.nuxt-loading-indicator.md +1 -1
- package/3.api/1.components/6.nuxt-error-boundary.md +12 -10
- package/3.api/2.composables/on-prehydrate.md +2 -2
- package/3.api/2.composables/use-app-config.md +1 -1
- package/3.api/2.composables/use-async-data.md +14 -14
- package/3.api/2.composables/use-cookie.md +27 -19
- package/3.api/2.composables/use-error.md +2 -2
- package/3.api/2.composables/use-fetch.md +17 -17
- package/3.api/2.composables/use-head-safe.md +5 -5
- package/3.api/2.composables/use-head.md +3 -3
- package/3.api/2.composables/use-hydration.md +5 -5
- package/3.api/2.composables/use-lazy-async-data.md +2 -2
- package/3.api/2.composables/use-lazy-fetch.md +2 -2
- package/3.api/2.composables/use-loading-indicator.md +10 -10
- package/3.api/2.composables/use-nuxt-app.md +10 -10
- package/3.api/2.composables/use-nuxt-data.md +7 -7
- package/3.api/2.composables/use-preview-mode.md +12 -15
- package/3.api/2.composables/use-request-fetch.md +1 -1
- package/3.api/2.composables/use-request-headers.md +3 -3
- package/3.api/2.composables/use-response-header.md +7 -8
- package/3.api/2.composables/use-route-announcer.md +3 -3
- package/3.api/2.composables/use-router.md +6 -4
- package/3.api/2.composables/use-runtime-config.md +11 -11
- package/3.api/2.composables/use-runtime-hook.md +1 -1
- package/3.api/2.composables/use-seo-meta.md +3 -3
- package/3.api/2.composables/use-server-seo-meta.md +3 -3
- package/3.api/2.composables/use-state.md +4 -4
- package/3.api/3.utils/$fetch.md +6 -4
- package/3.api/3.utils/abort-navigation.md +2 -2
- package/3.api/3.utils/add-route-middleware.md +3 -3
- package/3.api/3.utils/call-once.md +5 -5
- package/3.api/3.utils/clear-error.md +2 -2
- package/3.api/3.utils/clear-nuxt-data.md +2 -2
- package/3.api/3.utils/clear-nuxt-state.md +2 -2
- package/3.api/3.utils/create-error.md +2 -2
- package/3.api/3.utils/define-lazy-hydration-component.md +13 -13
- package/3.api/3.utils/define-nuxt-component.md +5 -5
- package/3.api/3.utils/define-nuxt-plugin.md +12 -12
- package/3.api/3.utils/define-nuxt-route-middleware.md +2 -2
- package/3.api/3.utils/define-page-meta.md +16 -16
- package/3.api/3.utils/define-route-rules.md +5 -5
- package/3.api/3.utils/navigate-to.md +10 -10
- package/3.api/3.utils/preload-components.md +1 -1
- package/3.api/3.utils/preload-route-components.md +2 -2
- package/3.api/3.utils/prerender-routes.md +2 -2
- package/3.api/3.utils/refresh-cookie.md +4 -4
- package/3.api/3.utils/refresh-nuxt-data.md +10 -5
- package/3.api/3.utils/reload-nuxt-app.md +3 -3
- package/3.api/3.utils/set-response-status.md +2 -2
- package/3.api/3.utils/show-error.md +3 -3
- package/3.api/3.utils/update-app-config.md +3 -2
- package/3.api/4.commands/generate.md +1 -1
- package/3.api/4.commands/prepare.md +4 -0
- package/3.api/4.commands/typecheck.md +1 -1
- package/3.api/5.kit/1.modules.md +36 -36
- package/3.api/5.kit/10.templates.md +8 -6
- package/3.api/5.kit/11.nitro.md +62 -62
- package/3.api/5.kit/12.resolving.md +2 -2
- package/3.api/5.kit/14.builder.md +1 -0
- package/3.api/5.kit/15.examples.md +2 -2
- package/3.api/5.kit/16.layers.md +26 -26
- package/3.api/5.kit/3.compatibility.md +12 -12
- package/3.api/5.kit/4.autoimports.md +12 -12
- package/3.api/5.kit/5.components.md +5 -5
- package/3.api/5.kit/6.context.md +3 -3
- package/3.api/5.kit/7.pages.md +4 -4
- package/3.api/5.kit/8.layout.md +1 -1
- package/3.api/5.kit/9.plugins.md +5 -4
- package/3.api/6.advanced/1.hooks.md +1 -1
- package/3.api/6.advanced/2.import-meta.md +3 -3
- package/3.api/6.nuxt-config.md +299 -864
- package/3.api/index.md +7 -7
- package/5.community/4.contribution.md +5 -5
- package/5.community/5.framework-contribution.md +1 -1
- package/6.bridge/1.overview.md +1 -1
- package/6.bridge/10.configuration.md +2 -1
- package/6.bridge/2.typescript.md +2 -2
- package/6.bridge/3.bridge-composition-api.md +4 -4
- package/6.bridge/4.plugins-and-middleware.md +5 -5
- package/6.bridge/5.nuxt3-compatible-api.md +12 -9
- package/6.bridge/6.meta.md +15 -14
- package/6.bridge/8.nitro.md +2 -2
- package/6.bridge/9.vite.md +3 -3
- package/7.migration/10.bundling.md +1 -1
- package/7.migration/11.server.md +3 -3
- package/7.migration/2.configuration.md +18 -16
- package/7.migration/20.module-authors.md +1 -1
- package/7.migration/4.meta.md +18 -15
- package/7.migration/5.plugins-and-middleware.md +8 -8
- package/7.migration/6.pages-and-layouts.md +20 -16
- package/7.migration/7.component-options.md +7 -7
- package/7.migration/8.runtime-config.md +4 -4
- package/package.json +1 -1
|
@@ -16,8 +16,8 @@ If your component is cached by `<KeepAlive>` and enters a deactivated state, the
|
|
|
16
16
|
|
|
17
17
|
## Type
|
|
18
18
|
|
|
19
|
-
```ts
|
|
20
|
-
refreshNuxtData(keys?: string | string[])
|
|
19
|
+
```ts [Signature]
|
|
20
|
+
export function refreshNuxtData (keys?: string | string[])
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## Parameters
|
|
@@ -50,7 +50,10 @@ async function refreshAll () {
|
|
|
50
50
|
|
|
51
51
|
<template>
|
|
52
52
|
<div>
|
|
53
|
-
<button
|
|
53
|
+
<button
|
|
54
|
+
:disabled="refreshing"
|
|
55
|
+
@click="refreshAll"
|
|
56
|
+
>
|
|
54
57
|
Refetch All Data
|
|
55
58
|
</button>
|
|
56
59
|
</div>
|
|
@@ -80,7 +83,9 @@ async function refresh () {
|
|
|
80
83
|
<div v-if="refreshing">
|
|
81
84
|
Loading
|
|
82
85
|
</div>
|
|
83
|
-
<button @click="refresh">
|
|
86
|
+
<button @click="refresh">
|
|
87
|
+
Refresh
|
|
88
|
+
</button>
|
|
84
89
|
</template>
|
|
85
90
|
```
|
|
86
91
|
|
|
@@ -88,4 +93,4 @@ async function refresh () {
|
|
|
88
93
|
If you have access to the `asyncData` instance, it is recommended to use its `refresh` or `execute` method as the preferred way to refetch the data.
|
|
89
94
|
::
|
|
90
95
|
|
|
91
|
-
:read-more{to="/docs/getting-started/data-fetching"}
|
|
96
|
+
:read-more{to="/docs/4.x/getting-started/data-fetching"}
|
|
@@ -14,14 +14,14 @@ links:
|
|
|
14
14
|
|
|
15
15
|
By default, it will also save the current `state` of your app (that is, any state you could access with `useState`).
|
|
16
16
|
|
|
17
|
-
::read-more{to="/docs/guide/going-further/experimental-features#restorestate" icon="i-lucide-star"}
|
|
17
|
+
::read-more{to="/docs/4.x/guide/going-further/experimental-features#restorestate" icon="i-lucide-star"}
|
|
18
18
|
You can enable experimental restoration of this state by enabling the `experimental.restoreState` option in your `nuxt.config` file.
|
|
19
19
|
::
|
|
20
20
|
|
|
21
21
|
## Type
|
|
22
22
|
|
|
23
|
-
```ts
|
|
24
|
-
reloadNuxtApp(options?: ReloadNuxtAppOptions)
|
|
23
|
+
```ts [Signature]
|
|
24
|
+
export function reloadNuxtApp (options?: ReloadNuxtAppOptions)
|
|
25
25
|
|
|
26
26
|
interface ReloadNuxtAppOptions {
|
|
27
27
|
ttl?: number
|
|
@@ -16,7 +16,7 @@ Nuxt provides composables and utilities for first-class server-side-rendering su
|
|
|
16
16
|
`setResponseStatus` can only be called in the [Nuxt context](/docs/4.x/guide/going-further/nuxt-app#the-nuxt-context).
|
|
17
17
|
::
|
|
18
18
|
|
|
19
|
-
```
|
|
19
|
+
```ts
|
|
20
20
|
const event = useRequestEvent()
|
|
21
21
|
|
|
22
22
|
// event will be undefined in the browser
|
|
@@ -33,4 +33,4 @@ if (event) {
|
|
|
33
33
|
In the browser, `setResponseStatus` will have no effect.
|
|
34
34
|
::
|
|
35
35
|
|
|
36
|
-
:read-more{to="/docs/getting-started/error-handling"}
|
|
36
|
+
:read-more{to="/docs/4.x/getting-started/error-handling"}
|
|
@@ -15,10 +15,10 @@ Within the [Nuxt context](/docs/4.x/guide/going-further/nuxt-app#the-nuxt-contex
|
|
|
15
15
|
- `error`: `string | Error | Partial<{ cause, data, message, name, stack, statusCode, statusMessage }>`
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
|
-
showError(
|
|
18
|
+
showError('😱 Oh no, an error has been thrown.')
|
|
19
19
|
showError({
|
|
20
20
|
statusCode: 404,
|
|
21
|
-
statusMessage:
|
|
21
|
+
statusMessage: 'Page Not Found',
|
|
22
22
|
})
|
|
23
23
|
```
|
|
24
24
|
|
|
@@ -28,4 +28,4 @@ The error is set in the state using [`useError()`](/docs/4.x/api/composables/use
|
|
|
28
28
|
`showError` calls the `app:error` hook.
|
|
29
29
|
::
|
|
30
30
|
|
|
31
|
-
:read-more{to="/docs/getting-started/error-handling"}
|
|
31
|
+
:read-more{to="/docs/4.x/getting-started/error-handling"}
|
|
@@ -15,13 +15,14 @@ Updates the [`app.config`](/docs/4.x/guide/directory-structure/app-config) using
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
17
|
```js
|
|
18
|
+
import { updateAppConfig, useAppConfig } from '#imports'
|
|
19
|
+
|
|
18
20
|
const appConfig = useAppConfig() // { foo: 'bar' }
|
|
19
21
|
|
|
20
22
|
const newAppConfig = { foo: 'baz' }
|
|
21
|
-
|
|
22
23
|
updateAppConfig(newAppConfig)
|
|
23
24
|
|
|
24
25
|
console.log(appConfig) // { foo: 'baz' }
|
|
25
26
|
```
|
|
26
27
|
|
|
27
|
-
:read-more{to="/docs/guide/directory-structure/app-config"}
|
|
28
|
+
:read-more{to="/docs/4.x/guide/directory-structure/app-config"}
|
|
@@ -36,6 +36,6 @@ Option | Default | Description
|
|
|
36
36
|
`--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
|
|
37
37
|
<!--/generate-opts-->
|
|
38
38
|
|
|
39
|
-
::read-more{to="/docs/getting-started/deployment#static-hosting"}
|
|
39
|
+
::read-more{to="/docs/4.x/getting-started/deployment#static-hosting"}
|
|
40
40
|
Read more about pre-rendering and static hosting.
|
|
41
41
|
::
|
|
@@ -34,3 +34,7 @@ Option | Default | Description
|
|
|
34
34
|
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
|
|
35
35
|
`--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
|
|
36
36
|
<!--/prepare-opts-->
|
|
37
|
+
|
|
38
|
+
::note
|
|
39
|
+
This command sets `process.env.NODE_ENV` to `production`.
|
|
40
|
+
::
|
|
@@ -37,6 +37,6 @@ Option | Default | Description
|
|
|
37
37
|
This command sets `process.env.NODE_ENV` to `production`. To override, define `NODE_ENV` in a [`.env`](/docs/4.x/guide/directory-structure/env) file or as a command-line argument.
|
|
38
38
|
::
|
|
39
39
|
|
|
40
|
-
::read-more{to="/docs/guide/concepts/typescript#type-checking"}
|
|
40
|
+
::read-more{to="/docs/4.x/guide/concepts/typescript#type-checking"}
|
|
41
41
|
Read more on how to enable type-checking at build or development time.
|
|
42
42
|
::
|
package/3.api/5.kit/1.modules.md
CHANGED
|
@@ -22,16 +22,16 @@ import { defineNuxtModule } from '@nuxt/kit'
|
|
|
22
22
|
export default defineNuxtModule({
|
|
23
23
|
meta: {
|
|
24
24
|
name: 'my-module',
|
|
25
|
-
configKey: 'myModule'
|
|
25
|
+
configKey: 'myModule',
|
|
26
26
|
},
|
|
27
27
|
defaults: {
|
|
28
|
-
enabled: true
|
|
28
|
+
enabled: true,
|
|
29
29
|
},
|
|
30
30
|
setup (options) {
|
|
31
31
|
if (options.enabled) {
|
|
32
32
|
console.log('My Nuxt module is enabled!')
|
|
33
33
|
}
|
|
34
|
-
}
|
|
34
|
+
},
|
|
35
35
|
})
|
|
36
36
|
```
|
|
37
37
|
|
|
@@ -78,17 +78,17 @@ import { defineNuxtModule } from '@nuxt/kit'
|
|
|
78
78
|
export default defineNuxtModule({
|
|
79
79
|
meta: {
|
|
80
80
|
name: 'my-module',
|
|
81
|
-
configKey: 'myModule'
|
|
81
|
+
configKey: 'myModule',
|
|
82
82
|
},
|
|
83
83
|
defaults: {
|
|
84
84
|
// Module options
|
|
85
|
-
enabled: true
|
|
85
|
+
enabled: true,
|
|
86
86
|
},
|
|
87
87
|
setup (options) {
|
|
88
88
|
if (options.enabled) {
|
|
89
89
|
console.log('My Nuxt module is enabled!')
|
|
90
90
|
}
|
|
91
|
-
}
|
|
91
|
+
},
|
|
92
92
|
})
|
|
93
93
|
```
|
|
94
94
|
|
|
@@ -97,8 +97,8 @@ Users can provide options for this module under the corresponding key in `nuxt.c
|
|
|
97
97
|
```ts
|
|
98
98
|
export default defineNuxtConfig({
|
|
99
99
|
myModule: {
|
|
100
|
-
enabled: false
|
|
101
|
-
}
|
|
100
|
+
enabled: false,
|
|
101
|
+
},
|
|
102
102
|
})
|
|
103
103
|
```
|
|
104
104
|
|
|
@@ -116,7 +116,7 @@ export default defineNuxtModule({
|
|
|
116
116
|
nuxt: '>=3.0.0', // or use '^3.0.0'
|
|
117
117
|
},
|
|
118
118
|
},
|
|
119
|
-
|
|
119
|
+
setup () {
|
|
120
120
|
const resolver = createResolver(import.meta.url)
|
|
121
121
|
// Implement
|
|
122
122
|
},
|
|
@@ -148,26 +148,26 @@ interface ModuleOptions {
|
|
|
148
148
|
export default defineNuxtModule<ModuleOptions>().with({
|
|
149
149
|
meta: {
|
|
150
150
|
name: '@nuxtjs/my-api',
|
|
151
|
-
configKey: 'myApi'
|
|
151
|
+
configKey: 'myApi',
|
|
152
152
|
},
|
|
153
153
|
defaults: {
|
|
154
154
|
baseURL: 'https://api.example.com',
|
|
155
155
|
timeout: 5000,
|
|
156
|
-
retries: 3
|
|
156
|
+
retries: 3,
|
|
157
157
|
},
|
|
158
|
-
setup(resolvedOptions, nuxt) {
|
|
158
|
+
setup (resolvedOptions, nuxt) {
|
|
159
159
|
// resolvedOptions is properly typed as:
|
|
160
160
|
// {
|
|
161
161
|
// apiKey: string // Required, no default provided
|
|
162
162
|
// baseURL: string // Required, has default value
|
|
163
163
|
// timeout: number // Optional, has default value
|
|
164
|
-
// retries: number // Optional, has default value
|
|
164
|
+
// retries: number // Optional, has default value
|
|
165
165
|
// }
|
|
166
|
-
|
|
166
|
+
|
|
167
167
|
console.log(resolvedOptions.baseURL) // ✅ TypeScript knows this is always defined
|
|
168
168
|
console.log(resolvedOptions.timeout) // ✅ TypeScript knows this is always defined
|
|
169
169
|
console.log(resolvedOptions.retries) // ✅ TypeScript knows this is always defined
|
|
170
|
-
}
|
|
170
|
+
},
|
|
171
171
|
})
|
|
172
172
|
```
|
|
173
173
|
|
|
@@ -197,45 +197,45 @@ export default defineNuxtModule({
|
|
|
197
197
|
meta: {
|
|
198
198
|
name: 'my-awesome-module',
|
|
199
199
|
version: '1.2.0', // Required for lifecycle hooks
|
|
200
|
-
configKey: 'myAwesomeModule'
|
|
200
|
+
configKey: 'myAwesomeModule',
|
|
201
201
|
},
|
|
202
202
|
defaults: {
|
|
203
203
|
apiKey: '',
|
|
204
|
-
enabled: true
|
|
204
|
+
enabled: true,
|
|
205
205
|
},
|
|
206
|
-
|
|
207
|
-
onInstall(nuxt) {
|
|
206
|
+
|
|
207
|
+
onInstall (nuxt) {
|
|
208
208
|
// This runs only when the module is first installed
|
|
209
209
|
console.log('Setting up my-awesome-module for the first time!')
|
|
210
|
-
|
|
210
|
+
|
|
211
211
|
// You might want to:
|
|
212
212
|
// - Create initial configuration files
|
|
213
213
|
// - Set up database schemas
|
|
214
214
|
// - Display welcome messages
|
|
215
215
|
// - Perform initial data migration
|
|
216
216
|
},
|
|
217
|
-
|
|
218
|
-
onUpgrade(options, nuxt, previousVersion) {
|
|
217
|
+
|
|
218
|
+
onUpgrade (options, nuxt, previousVersion) {
|
|
219
219
|
// This runs when the module is upgraded to a newer version
|
|
220
220
|
console.log(`Upgrading my-awesome-module from ${previousVersion} to 1.2.0`)
|
|
221
|
-
|
|
221
|
+
|
|
222
222
|
// You might want to:
|
|
223
223
|
// - Migrate configuration files
|
|
224
|
-
// - Update database schemas
|
|
224
|
+
// - Update database schemas
|
|
225
225
|
// - Clean up deprecated files
|
|
226
226
|
// - Display upgrade notes
|
|
227
|
-
|
|
227
|
+
|
|
228
228
|
if (semver.lt(previousVersion, '1.1.0')) {
|
|
229
229
|
console.log('⚠️ Breaking changes in 1.1.0 - please check the migration guide')
|
|
230
230
|
}
|
|
231
231
|
},
|
|
232
|
-
|
|
233
|
-
setup(options, nuxt) {
|
|
232
|
+
|
|
233
|
+
setup (options, nuxt) {
|
|
234
234
|
// Regular setup logic runs on every build
|
|
235
235
|
if (options.enabled) {
|
|
236
236
|
// Configure the module
|
|
237
237
|
}
|
|
238
|
-
}
|
|
238
|
+
},
|
|
239
239
|
})
|
|
240
240
|
```
|
|
241
241
|
|
|
@@ -248,7 +248,7 @@ Install specified Nuxt module programmatically. This is helpful when your module
|
|
|
248
248
|
```ts twoslash
|
|
249
249
|
import { defineNuxtModule, installModule } from '@nuxt/kit'
|
|
250
250
|
|
|
251
|
-
export default defineNuxtModule({
|
|
251
|
+
export default defineNuxtModule({
|
|
252
252
|
async setup () {
|
|
253
253
|
// will install @nuxtjs/fontaine with Roboto font and Impact fallback
|
|
254
254
|
await installModule('@nuxtjs/fontaine', {
|
|
@@ -258,10 +258,10 @@ export default defineNuxtModule({
|
|
|
258
258
|
family: 'Roboto',
|
|
259
259
|
fallbacks: ['Impact'],
|
|
260
260
|
fallbackName: 'fallback-a',
|
|
261
|
-
}
|
|
262
|
-
]
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
263
|
})
|
|
264
|
-
}
|
|
264
|
+
},
|
|
265
265
|
})
|
|
266
266
|
```
|
|
267
267
|
|
|
@@ -284,7 +284,7 @@ async function installModule (moduleToInstall: string | NuxtModule, inlineOption
|
|
|
284
284
|
```ts
|
|
285
285
|
import { defineNuxtModule, installModule } from '@nuxt/kit'
|
|
286
286
|
|
|
287
|
-
export default defineNuxtModule({
|
|
287
|
+
export default defineNuxtModule({
|
|
288
288
|
async setup (options, nuxt) {
|
|
289
289
|
// will install @nuxtjs/fontaine with Roboto font and Impact fallback
|
|
290
290
|
await installModule('@nuxtjs/fontaine', {
|
|
@@ -294,9 +294,9 @@ export default defineNuxtModule({
|
|
|
294
294
|
family: 'Roboto',
|
|
295
295
|
fallbacks: ['Impact'],
|
|
296
296
|
fallbackName: 'fallback-a',
|
|
297
|
-
}
|
|
298
|
-
]
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
299
|
})
|
|
300
|
-
}
|
|
300
|
+
},
|
|
301
301
|
})
|
|
302
302
|
```
|
|
@@ -21,17 +21,17 @@ import { addTemplate, defineNuxtModule } from '@nuxt/kit'
|
|
|
21
21
|
import { defu } from 'defu'
|
|
22
22
|
|
|
23
23
|
export default defineNuxtModule({
|
|
24
|
-
setup(options, nuxt) {
|
|
24
|
+
setup (options, nuxt) {
|
|
25
25
|
const globalMeta = defu(nuxt.options.app.head, {
|
|
26
26
|
charset: options.charset,
|
|
27
|
-
viewport: options.viewport
|
|
27
|
+
viewport: options.viewport,
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
addTemplate({
|
|
31
31
|
filename: 'meta.config.mjs',
|
|
32
|
-
getContents: () => 'export default ' + JSON.stringify({ globalMeta, mixinKey: 'setup' })
|
|
32
|
+
getContents: () => 'export default ' + JSON.stringify({ globalMeta, mixinKey: 'setup' }),
|
|
33
33
|
})
|
|
34
|
-
}
|
|
34
|
+
},
|
|
35
35
|
})
|
|
36
36
|
```
|
|
37
37
|
|
|
@@ -88,7 +88,7 @@ In the module above, we generate a virtual file named `meta.config.mjs`. In the
|
|
|
88
88
|
import { createHead as createServerHead } from '@unhead/vue/server'
|
|
89
89
|
import { createHead as createClientHead } from '@unhead/vue/client'
|
|
90
90
|
import { defineNuxtPlugin } from '#imports'
|
|
91
|
-
// @ts-
|
|
91
|
+
// @ts-expect-error - virtual file
|
|
92
92
|
import metaConfig from '#build/meta.config.mjs'
|
|
93
93
|
|
|
94
94
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
@@ -279,7 +279,9 @@ export default defineNuxtModule({
|
|
|
279
279
|
]
|
|
280
280
|
// watch and rebuild routes template list when one of the pages changes
|
|
281
281
|
nuxt.hook('builder:watch', async (event, relativePath) => {
|
|
282
|
-
if (event === 'change') {
|
|
282
|
+
if (event === 'change') {
|
|
283
|
+
return
|
|
284
|
+
}
|
|
283
285
|
|
|
284
286
|
const path = resolve(nuxt.options.srcDir, relativePath)
|
|
285
287
|
if (updateTemplatePaths.some(dir => path.startsWith(dir))) {
|