@nuxt/docs-nightly 4.4.3-29575944.80f44384 → 4.4.3-29608489.ff42fe25
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.
|
@@ -290,6 +290,25 @@ function setup () {
|
|
|
290
290
|
```
|
|
291
291
|
::
|
|
292
292
|
|
|
293
|
+
## Add Route Middleware
|
|
294
|
+
|
|
295
|
+
```ts
|
|
296
|
+
import { addRouteMiddleware, createResolver, defineNuxtModule } from '@nuxt/kit'
|
|
297
|
+
|
|
298
|
+
export default defineNuxtModule({
|
|
299
|
+
setup (options, nuxt) {
|
|
300
|
+
const resolver = createResolver(import.meta.url)
|
|
301
|
+
|
|
302
|
+
// example to add a global route middleware
|
|
303
|
+
addRouteMiddleware({
|
|
304
|
+
global: true,
|
|
305
|
+
name: 'name-of-your-middleware',
|
|
306
|
+
path: resolver.resolve('./runtime/middleware/name-of-your-middleware'),
|
|
307
|
+
})
|
|
308
|
+
},
|
|
309
|
+
})
|
|
310
|
+
```
|
|
311
|
+
|
|
293
312
|
## Add Server Routes
|
|
294
313
|
|
|
295
314
|
```ts
|
|
@@ -151,7 +151,7 @@ interface PageMeta {
|
|
|
151
151
|
|
|
152
152
|
- **Type**: `boolean | (to: RouteLocationNormalized, from: RouteLocationNormalized) => boolean`
|
|
153
153
|
|
|
154
|
-
Tell Nuxt to scroll to the top before rendering the page or not. If you want to overwrite the default scroll behavior of Nuxt, you can do so in `~/router.options.ts` (see [custom routing](/docs/4.x/guide/recipes/custom-routing#using-routeroptions)) for more info.
|
|
154
|
+
Tell Nuxt to scroll to the top before rendering the page or not. Navigation is independent from rendering, so scroll behavior is always triggered even when the page doesn't re-render (e.g. when using a fixed [`key`](/docs/4.x/api/utils/define-page-meta#key)). Set `scrollToTop: false` to disable scrolling in such cases. If you want to overwrite the default scroll behavior of Nuxt, you can do so in `~/router.options.ts` (see [custom routing](/docs/4.x/guide/recipes/custom-routing#using-routeroptions)) for more info.
|
|
155
155
|
|
|
156
156
|
**`[key: string]`**
|
|
157
157
|
|