docs: enable twoslash for some code snippets (#25679)

This commit is contained in:
Anthony Fu 2024-02-07 17:18:48 +01:00 committed by GitHub
parent ae83df8c43
commit 3c271413f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 68 additions and 59 deletions

View File

@ -34,7 +34,7 @@ Start with one of our starters and themes directly by opening [nuxt.new](https:/
If you have enabled **Take Over Mode** or installed the **TypeScript Vue Plugin (Volar)**, you can disable generating the shim for `*.vue` files in your [`nuxt.config.ts`](/docs/guide/directory-structure/nuxt-config) file: If you have enabled **Take Over Mode** or installed the **TypeScript Vue Plugin (Volar)**, you can disable generating the shim for `*.vue` files in your [`nuxt.config.ts`](/docs/guide/directory-structure/nuxt-config) file:
```ts [nuxt.config.ts] ```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({ export default defineNuxtConfig({
typescript: { typescript: {
shim: false shim: false

View File

@ -13,7 +13,7 @@ The [`nuxt.config.ts`](/docs/guide/directory-structure/nuxt-config) file is loca
A minimal configuration file exports the `defineNuxtConfig` function containing an object with your configuration. The `defineNuxtConfig` helper is globally available without import. A minimal configuration file exports the `defineNuxtConfig` function containing an object with your configuration. The `defineNuxtConfig` helper is globally available without import.
```ts [nuxt.config.ts] ```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({ export default defineNuxtConfig({
// My Nuxt config // My Nuxt config
}) })
@ -33,7 +33,7 @@ You don't have to use TypeScript to build an application with Nuxt. However, it
You can configure fully typed, per-environment overrides in your nuxt.config You can configure fully typed, per-environment overrides in your nuxt.config
```ts [nuxt.config.ts] ```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({ export default defineNuxtConfig({
$production: { $production: {
routeRules: { routeRules: {
@ -58,7 +58,7 @@ Those values should be defined in `nuxt.config` and can be overridden using envi
::code-group ::code-group
```ts [nuxt.config.ts] ```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({ export default defineNuxtConfig({
runtimeConfig: { runtimeConfig: {
// The private keys which are only available server-side // The private keys which are only available server-side
@ -164,7 +164,7 @@ If you need to pass options to `@vitejs/plugin-vue` or `@vitejs/plugin-vue-jsx`,
- `vite.vue` for `@vitejs/plugin-vue`. Check available options [here](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue). - `vite.vue` for `@vitejs/plugin-vue`. Check available options [here](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue).
- `vite.vueJsx` for `@vitejs/plugin-vue-jsx`. Check available options [here](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx). - `vite.vueJsx` for `@vitejs/plugin-vue-jsx`. Check available options [here](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx).
```ts [nuxt.config.ts] ```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({ export default defineNuxtConfig({
vite: { vite: {
vue: { vue: {
@ -183,7 +183,7 @@ export default defineNuxtConfig({
If you use webpack and need to configure `vue-loader`, you can do this using `webpack.loaders.vue` key inside your `nuxt.config` file. The available options are [defined here](https://github.com/vuejs/vue-loader/blob/main/src/index.ts#L32-L62). If you use webpack and need to configure `vue-loader`, you can do this using `webpack.loaders.vue` key inside your `nuxt.config` file. The available options are [defined here](https://github.com/vuejs/vue-loader/blob/main/src/index.ts#L32-L62).
```ts [nuxt.config.ts] ```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({ export default defineNuxtConfig({
webpack: { webpack: {
loaders: { loaders: {
@ -201,7 +201,7 @@ export default defineNuxtConfig({
You may need to enable experimental features in Vue, such as `propsDestructure`. Nuxt provides an easy way to do that in `nuxt.config.ts`, no matter which builder you are using: You may need to enable experimental features in Vue, such as `propsDestructure`. Nuxt provides an easy way to do that in `nuxt.config.ts`, no matter which builder you are using:
```ts [nuxt.config.ts] ```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({ export default defineNuxtConfig({
vue: { vue: {
propsDestructure: true propsDestructure: true

View File

@ -138,7 +138,7 @@ If you only need to modify the `<head>`, you can refer to the [SEO and meta sect
You can have full control over the HTML template by adding a Nitro plugin that registers a hook. You can have full control over the HTML template by adding a Nitro plugin that registers a hook.
The callback function of the `render:html` hook allows you to mutate the HTML before it is sent to the client. The callback function of the `render:html` hook allows you to mutate the HTML before it is sent to the client.
```ts [server/plugins/extend-html.ts] ```ts twoslash [server/plugins/extend-html.ts]
export default defineNitroPlugin((nitroApp) => { export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('render:html', (html, { event }) => { nitroApp.hooks.hook('render:html', (html, { event }) => {
// This will be an object representation of the html template. // This will be an object representation of the html template.

View File

@ -73,7 +73,7 @@ In your `nuxt.config`
::code-group ::code-group
```ts [SCSS] ```ts twoslash [SCSS]
export default defineNuxtConfig({ export default defineNuxtConfig({
vite: { vite: {
css: { css: {
@ -87,7 +87,7 @@ export default defineNuxtConfig({
}) })
``` ```
```ts [SASS] ```ts twoslash [SASS]
export default defineNuxtConfig({ export default defineNuxtConfig({
vite: { vite: {
css: { css: {

View File

@ -107,7 +107,7 @@ You can include external stylesheets in your application by adding a link elemen
You can manipulate the head with the [`app.head`](/docs/api/nuxt-config#head) property of your Nuxt configuration: You can manipulate the head with the [`app.head`](/docs/api/nuxt-config#head) property of your Nuxt configuration:
```ts [nuxt.config.ts] ```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({ export default defineNuxtConfig({
app: { app: {
head: { head: {
@ -122,7 +122,7 @@ You can use the useHead composable to dynamically set a value in your head in yo
:read-more{to="/docs/api/composables/use-head"} :read-more{to="/docs/api/composables/use-head"}
```ts ```ts twoslash
useHead({ useHead({
link: [{ rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css' }] link: [{ rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css' }]
}) })
@ -136,7 +136,7 @@ If you need more advanced control, you can intercept the rendered html with a ho
Create a plugin in `~/server/plugins/my-plugin.ts` like this: Create a plugin in `~/server/plugins/my-plugin.ts` like this:
```ts [server/plugins/my-plugin.ts] ```ts twoslash [server/plugins/my-plugin.ts]
export default defineNitroPlugin((nitro) => { export default defineNitroPlugin((nitro) => {
nitro.hooks.hook('render:html', (html) => { nitro.hooks.hook('render:html', (html) => {
html.head.push('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">') html.head.push('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">')
@ -177,7 +177,7 @@ You can then import your source files in your `app.vue` (or layouts files) using
Alternatively, you can use the `css` property of your Nuxt configuration. Alternatively, you can use the `css` property of your Nuxt configuration.
```ts [nuxt.config.ts] ```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({ export default defineNuxtConfig({
css: ['~/assets/scss/main.scss'] css: ['~/assets/scss/main.scss']
}) })
@ -209,7 +209,7 @@ Then in your `nuxt.config` :
::code-group ::code-group
```ts [SCSS] ```ts twoslash [SCSS]
export default defineNuxtConfig({ export default defineNuxtConfig({
vite: { vite: {
css: { css: {
@ -223,7 +223,7 @@ export default defineNuxtConfig({
}) })
``` ```
```ts [SASS] ```ts twoslash [SASS]
export default defineNuxtConfig({ export default defineNuxtConfig({
vite: { vite: {
css: { css: {

View File

@ -71,7 +71,7 @@ When a [`<NuxtLink>`](/docs/api/components/nuxt-link) enters the viewport on the
The [`useRoute()`](/docs/api/composables/use-route) composable can be used in a `<script setup>` block or a `setup()` method of a Vue component to access the current route details. The [`useRoute()`](/docs/api/composables/use-route) composable can be used in a `<script setup>` block or a `setup()` method of a Vue component to access the current route details.
```vue [pages/posts/[id\\].vue] ```vue twoslash [pages/posts/[id\\].vue]
<script setup lang="ts"> <script setup lang="ts">
const route = useRoute() const route = useRoute()
@ -100,7 +100,9 @@ Example of an `auth` middleware protecting the `/dashboard` page:
::code-group ::code-group
```ts [middleware/auth.ts] ```ts twoslash [middleware/auth.ts]
function isAuthenticated(): boolean { return false }
// ---cut---
export default defineNuxtRouteMiddleware((to, from) => { export default defineNuxtRouteMiddleware((to, from) => {
// isAuthenticated() is an example method verifying if a user is authenticated // isAuthenticated() is an example method verifying if a user is authenticated
if (isAuthenticated() === false) { if (isAuthenticated() === false) {
@ -109,7 +111,7 @@ export default defineNuxtRouteMiddleware((to, from) => {
}) })
``` ```
```html [pages/dashboard.vue] ```vue twoslash [pages/dashboard.vue]
<script setup lang="ts"> <script setup lang="ts">
definePageMeta({ definePageMeta({
middleware: 'auth' middleware: 'auth'
@ -133,7 +135,7 @@ The `validate` property accepts the `route` as an argument. You can return a boo
If you have a more complex use case, then you can use anonymous route middleware instead. If you have a more complex use case, then you can use anonymous route middleware instead.
```vue [pages/posts/[id\\].vue] ```vue twoslash [pages/posts/[id\\].vue]
<script setup lang="ts"> <script setup lang="ts">
definePageMeta({ definePageMeta({
validate: async (route) => { validate: async (route) => {

View File

@ -8,7 +8,7 @@ navigation.icon: i-ph-file-search-duotone
Out-of-the-box, Nuxt provides sane defaults, which you can override if needed. Out-of-the-box, Nuxt provides sane defaults, which you can override if needed.
```ts [nuxt.config.ts] ```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({ export default defineNuxtConfig({
app: { app: {
head: { head: {
@ -34,7 +34,7 @@ powered by [Unhead](https://unhead.unjs.io).
As with all composables, it can only be used with a components `setup` and lifecycle hooks. As with all composables, it can only be used with a components `setup` and lifecycle hooks.
```vue [app.vue] ```vue twoslash [app.vue]
<script setup lang="ts"> <script setup lang="ts">
useHead({ useHead({
title: 'My App', title: 'My App',
@ -57,7 +57,7 @@ The [`useSeoMeta`](/docs/api/composables/use-seo-meta) composable lets you defin
This helps you avoid typos and common mistakes, such as using `name` instead of `property`. This helps you avoid typos and common mistakes, such as using `name` instead of `property`.
```vue [app.vue] ```vue twoslash [app.vue]
<script setup lang="ts"> <script setup lang="ts">
useSeoMeta({ useSeoMeta({
title: 'My Amazing Site', title: 'My Amazing Site',
@ -92,7 +92,7 @@ const title = ref('Hello World')
<Head> <Head>
<Title>{{ title }}</Title> <Title>{{ title }}</Title>
<Meta name="description" :content="title" /> <Meta name="description" :content="title" />
<Style type="text/css" children="body { background-color: green; }" /> <Style type="text/css" children="body { background-color: green; }" ></Style>
</Head> </Head>
<h1>{{ title }}</h1> <h1>{{ title }}</h1>
@ -132,7 +132,7 @@ It's recommended to use getters (`() => value`) over computed (`computed(() => v
::code-group ::code-group
```vue [useHead] ```vue twoslash [useHead]
<script setup lang="ts"> <script setup lang="ts">
const description = ref('My amazing site.') const description = ref('My amazing site.')
@ -144,7 +144,7 @@ It's recommended to use getters (`() => value`) over computed (`computed(() => v
</script> </script>
``` ```
```vue [useSeoMeta] ```vue twoslash [useSeoMeta]
<script setup lang="ts"> <script setup lang="ts">
const description = ref('My amazing site.') const description = ref('My amazing site.')
@ -178,7 +178,7 @@ If you want to use a function (for full control), then this cannot be set in you
::code-group ::code-group
```vue [useHead] ```vue twoslash [useHead]
<script setup lang="ts"> <script setup lang="ts">
useHead({ useHead({
titleTemplate: (titleChunk) => { titleTemplate: (titleChunk) => {
@ -198,7 +198,7 @@ You can use the `tagPosition: 'bodyClose'` option on applicable tags to append t
For example: For example:
```vue ```vue twoslash
<script setup lang="ts"> <script setup lang="ts">
useHead({ useHead({
script: [ script: [
@ -220,7 +220,7 @@ Within your [`pages/` directory](/docs/guide/directory-structure/pages), you can
For example, you can first set the current page title (this is extracted at build time via a macro, so it can't be set dynamically): For example, you can first set the current page title (this is extracted at build time via a macro, so it can't be set dynamically):
```vue [pages/some-page.vue] ```vue twoslash [pages/some-page.vue]
<script setup lang="ts"> <script setup lang="ts">
definePageMeta({ definePageMeta({
title: 'Some Page' title: 'Some Page'
@ -230,7 +230,7 @@ definePageMeta({
And then in your layout file, you might use the route's metadata you have previously set: And then in your layout file, you might use the route's metadata you have previously set:
```vue [layouts/default.vue] ```vue twoslash [layouts/default.vue]
<script setup lang="ts"> <script setup lang="ts">
const route = useRoute() const route = useRoute()
@ -248,13 +248,20 @@ useHead({
In the example below, `titleTemplate` is set either as a string with the `%s` placeholder or as a `function`, which allows greater flexibility in setting the page title dynamically for each route of your Nuxt app: In the example below, `titleTemplate` is set either as a string with the `%s` placeholder or as a `function`, which allows greater flexibility in setting the page title dynamically for each route of your Nuxt app:
```vue [app.vue] ```vue twoslash [app.vue]
<script setup lang="ts"> <script setup lang="ts">
useHead({ useHead({
// as a string, // as a string,
// where `%s` is replaced with the title // where `%s` is replaced with the title
titleTemplate: '%s - Site Title', titleTemplate: '%s - Site Title',
// ... or as a function })
</script>
```
```vue twoslash [app.vue]
<script setup lang="ts">
useHead({
// or as a function
titleTemplate: (productCategory) => { titleTemplate: (productCategory) => {
return productCategory return productCategory
? `${productCategory} - Site Title` ? `${productCategory} - Site Title`
@ -272,7 +279,7 @@ The example below shows how you might enable Google Fonts using either the `link
::code-group ::code-group
```vue [useHead] ```vue twoslash [useHead]
<script setup lang="ts"> <script setup lang="ts">
useHead({ useHead({
link: [ link: [

View File

@ -12,7 +12,7 @@ Nuxt leverages Vue's [`<Transition>`](https://vuejs.org/guide/built-ins/transiti
You can enable page transitions to apply an automatic transition for all your [pages](/docs/guide/directory-structure/pages). You can enable page transitions to apply an automatic transition for all your [pages](/docs/guide/directory-structure/pages).
```ts [nuxt.config.ts] ```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({ export default defineNuxtConfig({
app: { app: {
pageTransition: { name: 'page', mode: 'out-in' } pageTransition: { name: 'page', mode: 'out-in' }
@ -28,7 +28,7 @@ To start adding transition between your pages, add the following CSS to your [`a
::code-group ::code-group
```html [app.vue] ```vue [app.vue]
<template> <template>
<NuxtPage /> <NuxtPage />
</template> </template>
@ -46,7 +46,7 @@ To start adding transition between your pages, add the following CSS to your [`a
</style> </style>
``` ```
```html [pages/index.vue] ```vue [pages/index.vue]
<template> <template>
<div> <div>
<h1>Home page</h1> <h1>Home page</h1>
@ -55,7 +55,7 @@ To start adding transition between your pages, add the following CSS to your [`a
</template> </template>
``` ```
```html [pages/about.vue] ```vue [pages/about.vue]
<template> <template>
<div> <div>
<h1>About page</h1> <h1>About page</h1>
@ -76,7 +76,7 @@ To set a different transition for a page, set the `pageTransition` key in [`defi
::code-group ::code-group
```vue [pages/about.vue] ```vue twoslash [pages/about.vue]
<script setup lang="ts"> <script setup lang="ts">
definePageMeta({ definePageMeta({
pageTransition: { pageTransition: {
@ -86,7 +86,7 @@ definePageMeta({
</script> </script>
``` ```
```html [app.vue] ```vue [app.vue]
<template> <template>
<NuxtPage /> <NuxtPage />
</template> </template>
@ -129,7 +129,7 @@ To start adding transition between your pages and layouts, add the following CSS
::code-group ::code-group
```html [app.vue] ```vue [app.vue]
<template> <template>
<NuxtLayout> <NuxtLayout>
<NuxtPage /> <NuxtPage />
@ -148,7 +148,7 @@ To start adding transition between your pages and layouts, add the following CSS
</style> </style>
``` ```
```html [layouts/default.vue] ```vue [layouts/default.vue]
<template> <template>
<div> <div>
<pre>default layout</pre> <pre>default layout</pre>
@ -163,7 +163,7 @@ div {
</style> </style>
``` ```
```html [layouts/orange.vue] ```vue [layouts/orange.vue]
<template> <template>
<div> <div>
<pre>orange layout</pre> <pre>orange layout</pre>
@ -180,7 +180,7 @@ div {
</style> </style>
``` ```
```html [pages/index.vue] ```vue [pages/index.vue]
<template> <template>
<div> <div>
<h1>Home page</h1> <h1>Home page</h1>
@ -189,7 +189,7 @@ div {
</template> </template>
``` ```
```html [pages/about.vue] ```vue [pages/about.vue]
<script setup lang="ts"> <script setup lang="ts">
definePageMeta({ definePageMeta({
layout: 'orange' layout: 'orange'
@ -231,7 +231,7 @@ You can customize these default transition names globally using `nuxt.config`.
Both `pageTransition` and `layoutTransition` keys accept [`TransitionProps`](https://vuejs.org/api/built-in-components.html#transition) as JSON serializable values where you can pass the `name`, `mode` and other valid transition-props of the custom CSS transition. Both `pageTransition` and `layoutTransition` keys accept [`TransitionProps`](https://vuejs.org/api/built-in-components.html#transition) as JSON serializable values where you can pass the `name`, `mode` and other valid transition-props of the custom CSS transition.
```ts [nuxt.config.ts] ```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({ export default defineNuxtConfig({
app: { app: {
pageTransition: { pageTransition: {
@ -252,7 +252,7 @@ If you change the `name` property, you also have to rename the CSS classes accor
To override the global transition property, use the `definePageMeta` to define page or layout transitions for a single Nuxt page and override any page or layout transitions that are defined globally in `nuxt.config` file. To override the global transition property, use the `definePageMeta` to define page or layout transitions for a single Nuxt page and override any page or layout transitions that are defined globally in `nuxt.config` file.
```vue [pages/some-page.vue] ```vue twoslash [pages/some-page.vue]
<script setup lang="ts"> <script setup lang="ts">
definePageMeta({ definePageMeta({
pageTransition: { pageTransition: {
@ -267,7 +267,7 @@ definePageMeta({
`pageTransition` and `layoutTransition` can be disabled for a specific route: `pageTransition` and `layoutTransition` can be disabled for a specific route:
```vue [pages/some-page.vue] ```vue twoslash [pages/some-page.vue]
<script setup lang="ts"> <script setup lang="ts">
definePageMeta({ definePageMeta({
pageTransition: false, pageTransition: false,
@ -278,8 +278,8 @@ definePageMeta({
Or globally in the `nuxt.config`: Or globally in the `nuxt.config`:
```ts [nuxt.config.ts] ```ts twoslash [nuxt.config.ts]
defineNuxtConfig({ export default defineNuxtConfig({
app: { app: {
pageTransition: false, pageTransition: false,
layoutTransition: false layoutTransition: false
@ -293,7 +293,7 @@ For advanced use-cases, you can use JavaScript hooks to create highly dynamic an
This way presents perfect use-cases for JavaScript animation libraries such as [GSAP](https://gsap.com). This way presents perfect use-cases for JavaScript animation libraries such as [GSAP](https://gsap.com).
```vue [pages/some-page.vue] ```vue twoslash [pages/some-page.vue]
<script setup lang="ts"> <script setup lang="ts">
definePageMeta({ definePageMeta({
pageTransition: { pageTransition: {
@ -319,7 +319,7 @@ To apply dynamic transitions using conditional logic, you can leverage inline [m
::code-group ::code-group
```html [pages/[id\\].vue] ```vue twoslash [pages/[id\\].vue]
<script setup lang="ts"> <script setup lang="ts">
definePageMeta({ definePageMeta({
pageTransition: { pageTransition: {
@ -362,7 +362,7 @@ definePageMeta({
</style> </style>
``` ```
```html [layouts/default.vue] ```vue [layouts/default.vue]
<script setup lang="ts"> <script setup lang="ts">
const route = useRoute() const route = useRoute()
const id = computed(() => Number(route.params.id || 1)) const id = computed(() => Number(route.params.id || 1))
@ -418,7 +418,7 @@ You can check a demo on https://nuxt-view-transitions.surge.sh and the [source o
The Nuxt integration is under active development, but can be enabled with the `experimental.viewTransition` option in your configuration file: The Nuxt integration is under active development, but can be enabled with the `experimental.viewTransition` option in your configuration file:
```ts [nuxt.config.ts] ```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({ export default defineNuxtConfig({
experimental: { experimental: {
viewTransition: true viewTransition: true
@ -432,7 +432,7 @@ If set to true, Nuxt will not apply transitions if the user's browser matches `p
By default, view transitions are enabled for all [pages](/docs/guide/directory-structure/pages), but you can set a different global default. By default, view transitions are enabled for all [pages](/docs/guide/directory-structure/pages), but you can set a different global default.
```ts [nuxt.config.ts] ```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({ export default defineNuxtConfig({
app: { app: {
// Disable view transitions globally, and opt-in on a per page basis // Disable view transitions globally, and opt-in on a per page basis
@ -443,7 +443,7 @@ export default defineNuxtConfig({
It is possible to override the default `viewTransition` value for a page by setting the `viewTransition` key in [`definePageMeta`](/docs/api/utils/define-page-meta) of the page: It is possible to override the default `viewTransition` value for a page by setting the `viewTransition` key in [`definePageMeta`](/docs/api/utils/define-page-meta) of the page:
```vue [pages/about.vue] ```vue twoslash [pages/about.vue]
<script setup lang="ts"> <script setup lang="ts">
definePageMeta({ definePageMeta({
viewTransition: false viewTransition: false
@ -457,7 +457,7 @@ Overriding view transitions on a per-page basis will only have an effect if you
If you are also using Vue transitions like `pageTransition` and `layoutTransition` (see above) to achieve the same result as the new View Transitions API, then you may wish to _disable_ Vue transitions if the user's browser supports the newer, native web API. You can do this by creating `~/middleware/disable-vue-transitions.global.ts` with the following contents: If you are also using Vue transitions like `pageTransition` and `layoutTransition` (see above) to achieve the same result as the new View Transitions API, then you may wish to _disable_ Vue transitions if the user's browser supports the newer, native web API. You can do this by creating `~/middleware/disable-vue-transitions.global.ts` with the following contents:
```js ```ts
export default defineNuxtRouteMiddleware(to => { export default defineNuxtRouteMiddleware(to => {
if (import.meta.server || !document.startViewTransition) { return } if (import.meta.server || !document.startViewTransition) { return }

View File

@ -123,7 +123,7 @@ const show = ref(false)
You can also explicitly import components from `#components` if you want or need to bypass Nuxt's auto-importing functionality. You can also explicitly import components from `#components` if you want or need to bypass Nuxt's auto-importing functionality.
```html [pages/index.vue] ```vue [pages/index.vue]
<script setup lang="ts"> <script setup lang="ts">
import { NuxtLink, LazyMountainsList } from '#components' import { NuxtLink, LazyMountainsList } from '#components'

View File

@ -48,6 +48,6 @@ The command searches for Nuxt modules matching your query that are compatible wi
**Example:** **Example:**
```base [Terminal] ```bash [Terminal]
npx nuxi module search pinia npx nuxi module search pinia
``` ```

View File

@ -30,7 +30,7 @@ You can now migrate to the Nuxt 3 middleware API, which is slightly different in
Middleware now take only two argument (`to`, `from`). You can find out more in [the docs](/docs/guide/directory-structure/middleware). Middleware now take only two argument (`to`, `from`). You can find out more in [the docs](/docs/guide/directory-structure/middleware).
```js ```ts twoslash
export default defineNuxtRouteMiddleware((to) => { export default defineNuxtRouteMiddleware((to) => {
if (to.path !== '/') { if (to.path !== '/') {
return navigateTo('/') return navigateTo('/')