Skip to content

Commit

Permalink
Merge branch 'canary' into fix-canonical-url-search-params
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed May 13, 2024
2 parents 2432a44 + 359fdb2 commit 3581f90
Show file tree
Hide file tree
Showing 62 changed files with 360 additions and 240 deletions.
167 changes: 123 additions & 44 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ swc_core = { version = "0.90.33", features = [
testing = { version = "0.35.22" }

# Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240508.4" }
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240513.1" }
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240508.4" }
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240513.1" }
# [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240508.4" }
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240513.1" }

# General Deps

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ You can modify the `<head>` HTML elements such as `title` and `meta` using the [
Metadata can be defined by exporting a [`metadata` object](/docs/app/api-reference/functions/generate-metadata#the-metadata-object) or [`generateMetadata` function](/docs/app/api-reference/functions/generate-metadata#generatemetadata-function) in a [`layout.js`](/docs/app/api-reference/file-conventions/layout) or [`page.js`](/docs/app/api-reference/file-conventions/page) file.

```tsx filename="app/page.tsx" switcher
import { Metadata } from 'next'
import type { Metadata } from 'next'

export const metadata: Metadata = {
title: 'Next.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ export function GET(request) {
Then, in the API Route:

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

type RedirectEntry = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ export const config = {
You can respond from Middleware directly by returning a `Response` or `NextResponse` instance. (This is available since [Next.js v13.1.0](https://nextjs.org/blog/next-13-1#nextjs-advanced-middleware))
```ts filename="middleware.ts" switcher
import { NextRequest } from 'next/server'
import type { NextRequest } from 'next/server'
import { isAuthenticated } from '@lib/auth'

// Limit the middleware to paths starting with `/api/`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Further, there is less code to be serialized, as un-rendered data does not cross
For [`getStaticProps`](/docs/pages/api-reference/functions/get-static-props), [`getStaticPaths`](/docs/pages/api-reference/functions/get-static-paths), and [`getServerSideProps`](/docs/pages/api-reference/functions/get-server-side-props), you can use the `GetStaticProps`, `GetStaticPaths`, and `GetServerSideProps` types respectively:

```tsx filename="pages/blog/[slug].tsx"
import { GetStaticProps, GetStaticPaths, GetServerSideProps } from 'next'
import type { GetStaticProps, GetStaticPaths, GetServerSideProps } from 'next'

export const getStaticProps = (async (context) => {
// ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ The form above has two input fields for capturing the user's email and password.
You can then call your Authentication Provider's API in the API route to handle authentication:

```ts filename="pages/api/auth/login.ts" switcher
import { NextApiRequest, NextApiResponse } from 'next'
import type { NextApiRequest, NextApiResponse } from 'next'
import { signIn } from '@/auth'

export default async function handler(
Expand Down Expand Up @@ -981,7 +981,7 @@ After implementing session management, you'll need to add authorization logic to

```ts filename="pages/api/create-session.ts" switcher
import db from '../../lib/db'
import { NextApiRequest, NextApiResponse } from 'next'
import type { NextApiRequest, NextApiResponse } from 'next'

export default async function handler(
req: NextApiRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export default function RootLayout({
To manage `<head>` HTML elements, you can use the [built-in SEO support](/docs/app/building-your-application/optimizing/metadata):

```tsx filename="app/layout.tsx" switcher
import { Metadata } from 'next'
import type { Metadata } from 'next'

export const metadata: Metadata = {
title: 'Home',
Expand Down Expand Up @@ -300,7 +300,7 @@ export default function Page() {
**After:**

```tsx filename="app/page.tsx" switcher
import { Metadata } from 'next'
import type { Metadata } from 'next'

export const metadata: Metadata = {
title: 'My Page Title',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Add or generate a `manifest.(json|webmanifest)` file that matches the [Web Manif
Add a `manifest.js` or `manifest.ts` file that returns a [`Manifest` object](#manifest-object).

```ts filename="app/manifest.ts" switcher
import { MetadataRoute } from 'next'
import type { MetadataRoute } from 'next'

export default function manifest(): MetadataRoute.Manifest {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Sitemap: https://acme.com/sitemap.xml
Add a `robots.js` or `robots.ts` file that returns a [`Robots` object](#robots-object).

```ts filename="app/robots.ts" switcher
import { MetadataRoute } from 'next'
import type { MetadataRoute } from 'next'

export default function robots(): MetadataRoute.Robots {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ For smaller applications, you can create a `sitemap.xml` file and place it in th
You can use the `sitemap.(js|ts)` file convention to programmatically **generate** a sitemap by exporting a default function that returns an array of URLs. If using TypeScript, a [`Sitemap`](#returns) type is available.

```ts filename="app/sitemap.ts" switcher
import { MetadataRoute } from 'next'
import type { MetadataRoute } from 'next'

export default function sitemap(): MetadataRoute.Sitemap {
return [
Expand Down Expand Up @@ -121,7 +121,7 @@ Output:
### Generate a localized Sitemap

```ts filename="app/sitemap.ts" switcher
import { MetadataRoute } from 'next'
import type { MetadataRoute } from 'next'

export default function sitemap(): MetadataRoute.Sitemap {
return [
Expand Down Expand Up @@ -214,7 +214,7 @@ There are two ways you can create multiple sitemaps:
For example, to split a sitemap using `generateSitemaps`, return an array of objects with the sitemap `id`. Then, use the `id` to generate the unique sitemaps.

```ts filename="app/product/sitemap.ts" switcher
import { MetadataRoute } from 'next'
import type { MetadataRoute } from 'next'
import { BASE_URL } from '@/app/lib/constants'

export async function generateSitemaps() {
Expand Down
18 changes: 9 additions & 9 deletions docs/02-app/02-api-reference/04-functions/generate-metadata.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ related:
This page covers all **Config-based Metadata** options with `generateMetadata` and the static metadata object.

```tsx filename="layout.tsx | page.tsx" switcher
import { Metadata } from 'next'
import type { Metadata } from 'next'

// either Static metadata
export const metadata: Metadata = {
Expand Down Expand Up @@ -53,7 +53,7 @@ export async function generateMetadata({ params }) {
To define static metadata, export a [`Metadata` object](#metadata-fields) from a `layout.js` or `page.js` file.

```tsx filename="layout.tsx | page.tsx" switcher
import { Metadata } from 'next'
import type { Metadata } from 'next'

export const metadata: Metadata = {
title: '...',
Expand All @@ -79,7 +79,7 @@ See the [Metadata Fields](#metadata-fields) for a complete list of supported opt
Dynamic metadata depends on **dynamic information**, such as the current route parameters, external data, or `metadata` in parent segments, can be set by exporting a `generateMetadata` function that returns a [`Metadata` object](#metadata-fields).

```tsx filename="app/products/[id]/page.tsx" switcher
import { Metadata, ResolvingMetadata } from 'next'
import type { Metadata, ResolvingMetadata } from 'next'

type Props = {
params: { id: string }
Expand Down Expand Up @@ -188,7 +188,7 @@ export const metadata = {
#### Template object
```tsx filename="app/layout.tsx" switcher
import { Metadata } from 'next'
import type { Metadata } from 'next'

export const metadata: Metadata = {
title: {
Expand Down Expand Up @@ -236,7 +236,7 @@ export const metadata: Metadata = {}
`title.template` can be used to add a prefix or a suffix to `titles` defined in **child** route segments.
```tsx filename="app/layout.tsx" switcher
import { Metadata } from 'next'
import type { Metadata } from 'next'

export const metadata: Metadata = {
title: {
Expand All @@ -256,7 +256,7 @@ export const metadata = {
```
```tsx filename="app/about/page.tsx" switcher
import { Metadata } from 'next'
import type { Metadata } from 'next'

export const metadata: Metadata = {
title: 'About',
Expand Down Expand Up @@ -288,7 +288,7 @@ export const metadata = {
`title.absolute` can be used to provide a title that **ignores** `title.template` set in parent segments.
```tsx filename="app/layout.tsx" switcher
import { Metadata } from 'next'
import type { Metadata } from 'next'

export const metadata: Metadata = {
title: {
Expand All @@ -306,7 +306,7 @@ export const metadata = {
```
```tsx filename="app/about/page.tsx" switcher
import { Metadata } from 'next'
import type { Metadata } from 'next'

export const metadata: Metadata = {
title: {
Expand Down Expand Up @@ -449,7 +449,7 @@ URL composition favors developer intent over default directory traversal semanti
For example, given the following `metadataBase`:
```tsx filename="app/layout.tsx" switcher
import { Metadata } from 'next'
import type { Metadata } from 'next'
export const metadata: Metadata = {
metadataBase: new URL('https://acme.com'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default async function submit() {

```ts filename="app/api/revalidate/route.ts" switcher
import { revalidatePath } from 'next/cache'
import { NextRequest } from 'next/server'
import type { NextRequest } from 'next/server'

export async function GET(request: NextRequest) {
const path = request.nextUrl.searchParams.get('path')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default async function submit() {
### Route Handler

```ts filename="app/api/revalidate/route.ts" switcher
import { NextRequest } from 'next/server'
import type { NextRequest } from 'next/server'
import { revalidateTag } from 'next/cache'

export async function GET(request: NextRequest) {
Expand Down
2 changes: 1 addition & 1 deletion examples/image-legacy-component/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Legacy Image Component Example

This example shows how to use the [Legacy Image Component in Next.js](https://nextjs.org/docs/api-reference/next/legacy/image) serve optimized, responsive images.
This example shows how to use the [Legacy Image Component in Next.js](https://nextjs.org/docs/api-reference/next/legacy/image) to serve optimized, responsive images.

The index page ([`pages/index.js`](pages/index.js)) has a couple images, one internal image and one external image. In [`next.config.js`](next.config.js), the `domains` property is used to enable external images. The other pages demonstrate the different layouts. Run or deploy the app to see how it works!

Expand Down
3 changes: 0 additions & 3 deletions examples/middleware/.eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions examples/middleware/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Middleware

This example shows how to use [Middleware in Next.js](https://nextjs.org/docs/advanced-features/middleware) to run code before a request is completed.
This example shows how to use [Middleware in Next.js](https://nextjs.org/docs/app/building-your-application/routing/middleware) to run code before a request is completed.

The index page ([`pages/index.tsx`](pages/index.tsx)) has a list of links to pages with `redirect`, `rewrite`, or normal behavior.
The index page ([`app/page.tsx`](app/page.tsx)) has a list of links to pages with `redirect`, `rewrite`, or normal behavior.

On the Middleware file ([`middleware.ts`](middleware.ts)) the routes are already being filtered by defining a `matcher` on the exported config. If you want the Middleware to run for every request, you can remove the `matcher`.

Expand Down
3 changes: 3 additions & 0 deletions examples/middleware/app/about/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function AboutPage() {
return <h1>About</h1>;
}
3 changes: 3 additions & 0 deletions examples/middleware/app/about2/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function About2Page() {
return <h1>About 2</h1>;
}
3 changes: 3 additions & 0 deletions examples/middleware/app/another/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function AnotherPage() {
return <h1>Another</h1>;
}
18 changes: 18 additions & 0 deletions examples/middleware/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Metadata } from "next";

export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}

export const metadata: Metadata = {
title: "Next.js Middleware example",
description: "Redirect and rewrite pages using Next.js Middleware.",
};
18 changes: 18 additions & 0 deletions examples/middleware/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Link from "next/link";

export default function Home() {
return (
<div>
<h1>Index</h1>
<p>
<Link href="/about">Go to about page (will redirect)</Link>
</p>
<p>
<Link href="/another">Go to another page (will rewrite)</Link>
</p>
<p>
<Link href="/about2">Go to about 2 page (no redirect or rewrite)</Link>
</p>
</div>
);
}
3 changes: 3 additions & 0 deletions examples/middleware/app/redirected/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function RedirectedPage() {
return <h1>Redirected from /about</h1>;
}
3 changes: 3 additions & 0 deletions examples/middleware/app/rewrite/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function RewritePage() {
return <h1>Rewrite</h1>;
}
6 changes: 0 additions & 6 deletions examples/middleware/next.config.js

This file was deleted.

7 changes: 0 additions & 7 deletions examples/middleware/pages/_app.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions examples/middleware/pages/about.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions examples/middleware/pages/about2.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions examples/middleware/pages/another.tsx

This file was deleted.

27 changes: 0 additions & 27 deletions examples/middleware/pages/index.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions examples/middleware/pages/redirected.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions examples/middleware/pages/rewrite.tsx

This file was deleted.

0 comments on commit 3581f90

Please sign in to comment.