-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### What Fixes metadata merging issue on 14.2. There's a bug with React on 14.2 as it bit outdated: while generating rsc payload, if we use fragment to wrap the metadata and noindex component, it will miss all the data. It works well with separating them as an array. It also requires #64058 to be applied as well so the output not-found page will having correct status 404, and then we can generate noindex metatag based on correct status Fixes #69778
- Loading branch information
Showing
10 changed files
with
120 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
test/e2e/app-dir/metadata-navigation/app/(cart)/product/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Metadata } from 'next' | ||
|
||
export const metadata: Metadata = { | ||
title: 'Product Layout', | ||
} | ||
|
||
export default function Layout({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode | ||
}>) { | ||
return <>{children}</> | ||
} |
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/metadata-navigation/app/(cart)/product/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page() { | ||
return <div>Product page content</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
type LayoutProps = { | ||
children: React.ReactNode | ||
} | ||
|
||
export default function Layout({ children }: LayoutProps) { | ||
return <div>{children}</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Link from 'next/link' | ||
|
||
export default function Page() { | ||
return ( | ||
<div> | ||
<div>Home header</div> | ||
<Link href="/product" id="product-link"> | ||
Product | ||
</Link> | ||
</div> | ||
) | ||
} |
7 changes: 7 additions & 0 deletions
7
test/e2e/app-dir/metadata-navigation/app/@header/product/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
type LayoutProps = { | ||
children: React.ReactNode | ||
} | ||
|
||
export default function Layout({ children }: LayoutProps) { | ||
return <>{children}</> | ||
} |
12 changes: 12 additions & 0 deletions
12
test/e2e/app-dir/metadata-navigation/app/@header/product/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Link from 'next/link' | ||
|
||
export default function Page() { | ||
return ( | ||
<div> | ||
<h1 id="product-title">Product header</h1> | ||
<Link href="/" id="home-link"> | ||
Go to Home page | ||
</Link> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { Metadata } from 'next' | ||
|
||
export const metadata: Metadata = { | ||
title: 'Home Layout', | ||
description: 'Generated by create next app', | ||
} | ||
|
||
export default function RootLayout({ | ||
header, | ||
children, | ||
}: Readonly<{ | ||
header: React.ReactNode | ||
children: React.ReactNode | ||
}>) { | ||
return ( | ||
<html lang="en"> | ||
<body className={`antialiased bg-gray-50 text-black`}> | ||
{header} | ||
{children} | ||
</body> | ||
</html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Home() { | ||
return ( | ||
<div> | ||
<h3 id="home-title">Home page content</h3> | ||
</div> | ||
) | ||
} |
30 changes: 30 additions & 0 deletions
30
test/e2e/app-dir/metadata-navigation/metadata-navigation.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { createNextDescribe } from 'e2e-utils' | ||
|
||
createNextDescribe( | ||
'app-dir - metadata-navigation', | ||
{ | ||
files: __dirname, | ||
}, | ||
({ next }) => { | ||
it('should show the index title', async () => { | ||
const browser = await next.browser('/') | ||
expect(await browser.elementByCss('title').text()).toBe('Home Layout') | ||
}) | ||
|
||
it('should show target page metadata after navigation', async () => { | ||
const browser = await next.browser('/') | ||
await browser.elementByCss('#product-link').click() | ||
await browser.waitForElementByCss('#product-title') | ||
expect(await browser.elementByCss('title').text()).toBe('Product Layout') | ||
}) | ||
|
||
it('should show target page metadata after navigation with back', async () => { | ||
const browser = await next.browser('/') | ||
await browser.elementByCss('#product-link').click() | ||
await browser.waitForElementByCss('#product-title') | ||
await browser.elementByCss('#home-link').click() | ||
await browser.waitForElementByCss('#home-title') | ||
expect(await browser.elementByCss('title').text()).toBe('Home Layout') | ||
}) | ||
} | ||
) |