Skip to content

Commit

Permalink
docs: fix code block language in redirecting docs (vercel#72944)
Browse files Browse the repository at this point in the history
## Summary
Update incorrect code block languages at [redirecting
document](https://github.com/vercel/next.js/blob/canary/docs/01-app/02-building-your-application/01-routing/07-redirecting.mdx).

### Improving Documentation

- [x] Run `pnpm prettier-fix` to fix formatting issues before opening
the PR.
- [x] Read the Docs Contribution Guide to ensure your contribution
follows the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
  • Loading branch information
JamBalaya56562 and delbaoliveira authored Nov 19, 2024
1 parent 0714c45 commit 0a7d97e
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The `redirect` function allows you to redirect the user to another URL. You can

`redirect` is often used after a mutation or event. For example, creating a post:

```tsx filename="app/actions.tsx" switcher
```ts filename="app/actions.ts" switcher
'use server'

import { redirect } from 'next/navigation'
Expand All @@ -59,7 +59,7 @@ export async function createPost(id: string) {
}
```

```jsx filename="app/actions.js" switcher
```js filename="app/actions.js" switcher
'use server'

import { redirect } from 'next/navigation'
Expand Down Expand Up @@ -93,7 +93,7 @@ The `permanentRedirect` function allows you to **permanently** redirect the user

`permanentRedirect` is often used after a mutation or event that changes an entity's canonical URL, such as updating a user's profile URL after they change their username:

```tsx filename="app/actions.ts" switcher
```ts filename="app/actions.ts" switcher
'use server'

import { permanentRedirect } from 'next/navigation'
Expand All @@ -111,7 +111,7 @@ export async function updateUsername(username: string, formData: FormData) {
}
```

```jsx filename="app/actions.js" switcher
```js filename="app/actions.js" switcher
'use server'

import { permanentRedirect } from 'next/navigation'
Expand Down Expand Up @@ -272,7 +272,7 @@ Middleware allows you to run code before a request is completed. Then, based on

For example, to redirect the user to a `/login` page if they are not authenticated:

```tsx filename="middleware.ts" switcher
```ts filename="middleware.ts" switcher
import { NextResponse, NextRequest } from 'next/server'
import { authenticate } from 'auth-provider'

Expand Down Expand Up @@ -352,7 +352,7 @@ Consider the following data structure:

In [Middleware](/docs/app/building-your-application/routing/middleware), you can read from a database such as Vercel's [Edge Config](https://vercel.com/docs/storage/edge-config/get-started?utm_source=next-site&utm_medium=docs&utm_campaign=next-website) or [Redis](https://vercel.com/docs/storage/vercel-kv?utm_source=next-site&utm_medium=docs&utm_campaign=next-website), and redirect the user based on the incoming request:

```tsx filename="middleware.ts" switcher
```ts filename="middleware.ts" switcher
import { NextResponse, NextRequest } from 'next/server'
import { get } from '@vercel/edge-config'

Expand Down Expand Up @@ -406,7 +406,7 @@ Considering the previous example, you can import a generated bloom filter file i

If it does, forward the request to a <AppOnly>[Route Handler](/docs/app/building-your-application/routing/route-handlers)</AppOnly> <PagesOnly>[API Routes](/docs/pages/building-your-application/routing/api-routes)</PagesOnly> which will check the actual file and redirect the user to the appropriate URL. This avoids importing a large redirects file into Middleware, which can slow down every incoming request.

```tsx filename="middleware.ts" switcher
```ts filename="middleware.ts" switcher
import { NextResponse, NextRequest } from 'next/server'
import { ScalableBloomFilter } from 'bloom-filters'
import GeneratedBloomFilter from './redirects/bloom-filter.json'
Expand Down Expand Up @@ -506,7 +506,7 @@ export async function middleware(request) {

Then, in the Route Handler:

```tsx filename="app/redirects/route.ts" switcher
```ts filename="app/redirects/route.ts" switcher
import { NextRequest, NextResponse } from 'next/server'
import redirects from '@/app/redirects/redirects.json'

Expand Down Expand Up @@ -563,7 +563,7 @@ export function GET(request) {

Then, in the API Route:

```tsx filename="pages/api/redirects.ts" switcher
```ts filename="pages/api/redirects.ts" switcher
import type { NextApiRequest, NextApiResponse } from 'next'
import redirects from '@/app/redirects/redirects.json'

Expand Down

0 comments on commit 0a7d97e

Please sign in to comment.