@nuxt/docs-nightly 4.2.1-29369624.1cc53932 → 4.2.1-29370820.95518afa
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/18.upgrade.md +1 -1
- package/2.guide/1.directory-structure/3.tsconfig.md +1 -1
- package/3.api/2.composables/use-async-data.md +2 -2
- package/3.api/2.composables/use-cookie.md +1 -1
- package/3.api/2.composables/use-fetch.md +1 -1
- package/3.api/2.composables/use-head-safe.md +1 -17
- package/3.api/2.composables/use-head.md +20 -20
- package/3.api/2.composables/use-lazy-async-data.md +11 -5
- package/3.api/2.composables/use-lazy-fetch.md +1 -1
- package/3.api/2.composables/use-runtime-hook.md +1 -1
- package/3.api/3.utils/navigate-to.md +1 -1
- package/3.api/5.kit/1.modules.md +1 -1
- package/package.json +1 -1
|
@@ -234,12 +234,12 @@ export type AsyncDataHandler<ResT> = (nuxtApp: NuxtApp, options: { signal: Abort
|
|
|
234
234
|
|
|
235
235
|
export function useAsyncData<DataT, DataE> (
|
|
236
236
|
handler: AsyncDataHandler<DataT>,
|
|
237
|
-
options?: AsyncDataOptions<DataT
|
|
237
|
+
options?: AsyncDataOptions<DataT>,
|
|
238
238
|
): AsyncData<DataT, DataE>
|
|
239
239
|
export function useAsyncData<DataT, DataE> (
|
|
240
240
|
key: MaybeRefOrGetter<string>,
|
|
241
241
|
handler: AsyncDataHandler<DataT>,
|
|
242
|
-
options?: AsyncDataOptions<DataT
|
|
242
|
+
options?: AsyncDataOptions<DataT>,
|
|
243
243
|
): Promise<AsyncData<DataT, DataE>>
|
|
244
244
|
|
|
245
245
|
type AsyncDataOptions<DataT> = {
|
|
@@ -128,7 +128,7 @@ searchQuery.value = 'new search'
|
|
|
128
128
|
```ts [Signature]
|
|
129
129
|
export function useFetch<DataT, ErrorT> (
|
|
130
130
|
url: string | Request | Ref<string | Request> | (() => string | Request),
|
|
131
|
-
options?: UseFetchOptions<DataT
|
|
131
|
+
options?: UseFetchOptions<DataT>,
|
|
132
132
|
): Promise<AsyncData<DataT, ErrorT>>
|
|
133
133
|
|
|
134
134
|
type UseFetchOptions<DataT> = {
|
|
@@ -12,22 +12,6 @@ links:
|
|
|
12
12
|
|
|
13
13
|
The `useHeadSafe` composable is a wrapper around the [`useHead`](/docs/4.x/api/composables/use-head) composable that restricts the input to only allow safe values. This is the recommended way to manage head data when working with user input, as it prevents XSS attacks by sanitizing potentially dangerous attributes.
|
|
14
14
|
|
|
15
|
-
```vue [app/app.vue]
|
|
16
|
-
<script setup lang="ts">
|
|
17
|
-
useHeadSafe({
|
|
18
|
-
script: [
|
|
19
|
-
{ id: 'xss-script', innerHTML: 'alert("xss")' },
|
|
20
|
-
],
|
|
21
|
-
meta: [
|
|
22
|
-
{ 'http-equiv': 'refresh', content: '0;javascript:alert(1)' },
|
|
23
|
-
],
|
|
24
|
-
})
|
|
25
|
-
// Will safely generate
|
|
26
|
-
// <script id="xss-script"></script>
|
|
27
|
-
// <meta content="0;javascript:alert(1)">
|
|
28
|
-
</script>
|
|
29
|
-
```
|
|
30
|
-
|
|
31
15
|
::warning
|
|
32
16
|
When using `useHeadSafe`, potentially dangerous attributes like `innerHTML` in scripts or `http-equiv` in meta tags are automatically stripped out to prevent XSS attacks. Use this composable whenever you're working with user-generated content.
|
|
33
17
|
::
|
|
@@ -69,7 +53,7 @@ This composable does not return any value.
|
|
|
69
53
|
```vue [app/pages/user-profile.vue]
|
|
70
54
|
<script setup lang="ts">
|
|
71
55
|
// User-generated content that might contain malicious code
|
|
72
|
-
const userBio = ref('<script>alert("xss")
|
|
56
|
+
const userBio = ref('<script>alert("xss")<' + '/script>')
|
|
73
57
|
|
|
74
58
|
useHeadSafe({
|
|
75
59
|
title: `User Profile`,
|
|
@@ -17,12 +17,12 @@ The `useHead` composable allows you to manage your head tags in a programmatic a
|
|
|
17
17
|
useHead({
|
|
18
18
|
title: 'My App',
|
|
19
19
|
meta: [
|
|
20
|
-
{ name: 'description', content: 'My amazing site.' }
|
|
20
|
+
{ name: 'description', content: 'My amazing site.' },
|
|
21
21
|
],
|
|
22
22
|
bodyAttrs: {
|
|
23
|
-
class: 'test'
|
|
23
|
+
class: 'test',
|
|
24
24
|
},
|
|
25
|
-
script: [{ innerHTML: 'console.log(\'Hello world\')' }]
|
|
25
|
+
script: [{ innerHTML: 'console.log(\'Hello world\')' }],
|
|
26
26
|
})
|
|
27
27
|
</script>
|
|
28
28
|
```
|
|
@@ -88,8 +88,8 @@ useHead({
|
|
|
88
88
|
meta: [
|
|
89
89
|
{ name: 'description', content: 'Learn more about our company' },
|
|
90
90
|
{ property: 'og:title', content: 'About Us' },
|
|
91
|
-
{ property: 'og:description', content: 'Learn more about our company' }
|
|
92
|
-
]
|
|
91
|
+
{ property: 'og:description', content: 'Learn more about our company' },
|
|
92
|
+
],
|
|
93
93
|
})
|
|
94
94
|
</script>
|
|
95
95
|
```
|
|
@@ -103,11 +103,11 @@ const profile = ref({ name: 'John Doe' })
|
|
|
103
103
|
useHead({
|
|
104
104
|
title: computed(() => profile.value.name),
|
|
105
105
|
meta: [
|
|
106
|
-
{
|
|
107
|
-
name: 'description',
|
|
108
|
-
content: computed(() => `Profile page for ${profile.value.name}`)
|
|
109
|
-
}
|
|
110
|
-
]
|
|
106
|
+
{
|
|
107
|
+
name: 'description',
|
|
108
|
+
content: computed(() => `Profile page for ${profile.value.name}`),
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
111
|
})
|
|
112
112
|
</script>
|
|
113
113
|
```
|
|
@@ -121,8 +121,8 @@ const count = ref(0)
|
|
|
121
121
|
useHead(() => ({
|
|
122
122
|
title: `Count: ${count.value}`,
|
|
123
123
|
meta: [
|
|
124
|
-
{ name: 'description', content: `Current count is ${count.value}` }
|
|
125
|
-
]
|
|
124
|
+
{ name: 'description', content: `Current count is ${count.value}` },
|
|
125
|
+
],
|
|
126
126
|
}))
|
|
127
127
|
</script>
|
|
128
128
|
```
|
|
@@ -135,15 +135,15 @@ useHead({
|
|
|
135
135
|
link: [
|
|
136
136
|
{
|
|
137
137
|
rel: 'stylesheet',
|
|
138
|
-
href: 'https://cdn.example.com/styles.css'
|
|
139
|
-
}
|
|
138
|
+
href: 'https://cdn.example.com/styles.css',
|
|
139
|
+
},
|
|
140
140
|
],
|
|
141
141
|
script: [
|
|
142
142
|
{
|
|
143
143
|
src: 'https://cdn.example.com/script.js',
|
|
144
|
-
async: true
|
|
145
|
-
}
|
|
146
|
-
]
|
|
144
|
+
async: true,
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
147
|
})
|
|
148
148
|
</script>
|
|
149
149
|
```
|
|
@@ -157,11 +157,11 @@ const isDark = ref(true)
|
|
|
157
157
|
useHead({
|
|
158
158
|
htmlAttrs: {
|
|
159
159
|
lang: 'en',
|
|
160
|
-
class: computed(() => isDark.value ? 'dark' : 'light')
|
|
160
|
+
class: computed(() => isDark.value ? 'dark' : 'light'),
|
|
161
161
|
},
|
|
162
162
|
bodyAttrs: {
|
|
163
|
-
class: 'themed-page'
|
|
164
|
-
}
|
|
163
|
+
class: 'themed-page',
|
|
164
|
+
},
|
|
165
165
|
})
|
|
166
166
|
</script>
|
|
167
167
|
```
|
|
@@ -23,9 +23,15 @@ const { status, data: posts } = await useLazyAsyncData('posts', () => $fetch('/a
|
|
|
23
23
|
|
|
24
24
|
<template>
|
|
25
25
|
<div>
|
|
26
|
-
<div v-if="status === 'pending'">
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
<div v-if="status === 'pending'">
|
|
27
|
+
Loading...
|
|
28
|
+
</div>
|
|
29
|
+
<div v-else-if="status === 'error'">
|
|
30
|
+
Error loading posts
|
|
31
|
+
</div>
|
|
32
|
+
<div v-else>
|
|
33
|
+
{{ posts }}
|
|
34
|
+
</div>
|
|
29
35
|
</div>
|
|
30
36
|
</template>
|
|
31
37
|
```
|
|
@@ -41,13 +47,13 @@ When using `useLazyAsyncData`, navigation will occur before fetching is complete
|
|
|
41
47
|
```ts [Signature]
|
|
42
48
|
export function useLazyAsyncData<DataT, ErrorT> (
|
|
43
49
|
handler: (ctx?: NuxtApp) => Promise<DataT>,
|
|
44
|
-
options?: AsyncDataOptions<DataT
|
|
50
|
+
options?: AsyncDataOptions<DataT>,
|
|
45
51
|
): AsyncData<DataT, ErrorT>
|
|
46
52
|
|
|
47
53
|
export function useLazyAsyncData<DataT, ErrorT> (
|
|
48
54
|
key: string,
|
|
49
55
|
handler: (ctx?: NuxtApp) => Promise<DataT>,
|
|
50
|
-
options?: AsyncDataOptions<DataT
|
|
56
|
+
options?: AsyncDataOptions<DataT>,
|
|
51
57
|
): AsyncData<DataT, ErrorT>
|
|
52
58
|
```
|
|
53
59
|
|
|
@@ -48,7 +48,7 @@ Awaiting `useLazyFetch` only ensures the call is initialized. On client-side nav
|
|
|
48
48
|
```ts [Signature]
|
|
49
49
|
export function useLazyFetch<DataT, ErrorT> (
|
|
50
50
|
url: string | Request | Ref<string | Request> | (() => string | Request),
|
|
51
|
-
options?: UseFetchOptions<DataT
|
|
51
|
+
options?: UseFetchOptions<DataT>,
|
|
52
52
|
): Promise<AsyncData<DataT, ErrorT>>
|
|
53
53
|
```
|
|
54
54
|
|
|
@@ -15,7 +15,7 @@ This composable is available in Nuxt v3.14+.
|
|
|
15
15
|
```ts [signature]
|
|
16
16
|
function useRuntimeHook<THookName extends keyof RuntimeNuxtHooks> (
|
|
17
17
|
name: THookName,
|
|
18
|
-
fn: RuntimeNuxtHooks[THookName] extends HookCallback ? RuntimeNuxtHooks[THookName] : never
|
|
18
|
+
fn: RuntimeNuxtHooks[THookName] extends HookCallback ? RuntimeNuxtHooks[THookName] : never,
|
|
19
19
|
): void
|
|
20
20
|
```
|
|
21
21
|
|
|
@@ -119,7 +119,7 @@ await navigateTo('https://nuxt.com', {
|
|
|
119
119
|
```ts [Signature]
|
|
120
120
|
export function navigateTo (
|
|
121
121
|
to: RouteLocationRaw | undefined | null,
|
|
122
|
-
options?: NavigateToOptions
|
|
122
|
+
options?: NavigateToOptions,
|
|
123
123
|
): Promise<void | NavigationFailure | false> | false | void | RouteLocationRaw
|
|
124
124
|
|
|
125
125
|
interface NavigateToOptions {
|
package/3.api/5.kit/1.modules.md
CHANGED
|
@@ -47,7 +47,7 @@ export function defineNuxtModule<TOptions extends ModuleOptions> (
|
|
|
47
47
|
|
|
48
48
|
export function defineNuxtModule<TOptions extends ModuleOptions> (): {
|
|
49
49
|
with: <TOptionsDefaults extends Partial<TOptions>> (
|
|
50
|
-
definition: ModuleDefinition<TOptions, TOptionsDefaults, true> | NuxtModule<TOptions, TOptionsDefaults, true
|
|
50
|
+
definition: ModuleDefinition<TOptions, TOptionsDefaults, true> | NuxtModule<TOptions, TOptionsDefaults, true>,
|
|
51
51
|
) => NuxtModule<TOptions, TOptionsDefaults, true>
|
|
52
52
|
}
|
|
53
53
|
```
|