-
Notifications
You must be signed in to change notification settings - Fork 28.4k
fix: ignore metadata from default.js #75669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,19 @@ | ||
import Link from 'next/link' | ||
import React from 'react' | ||
|
||
export default function Root({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<html> | ||
<body> | ||
<div> | ||
<Link href="/nested">to nested</Link> | ||
</div> | ||
<div> | ||
<Link href="/nested/subroute">to nested subroute</Link> | ||
</div> | ||
<h1>Root Layout</h1> | ||
<div>{children}</div> | ||
</body> | ||
</html> | ||
) | ||
} |
11 changes: 11 additions & 0 deletions
11
test/e2e/app-dir/metadata-parallel-routes/app/nested/@bar/default.tsx
This file contains hidden or 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,11 @@ | ||
export default function Default() { | ||
console.log( | ||
'@bar default page', | ||
typeof window !== 'undefined' ? 'client' : 'server' | ||
) | ||
return '@bar default' | ||
} | ||
|
||
export const metadata = { | ||
title: '@bar - page', | ||
} |
8 changes: 8 additions & 0 deletions
8
test/e2e/app-dir/metadata-parallel-routes/app/nested/@bar/layout.tsx
This file contains hidden or 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,8 @@ | ||
export default function Layout({ children }) { | ||
return ( | ||
<div> | ||
<h1>@bar Layout</h1> | ||
<div id="bar-children">{children}</div> | ||
</div> | ||
) | ||
} |
7 changes: 7 additions & 0 deletions
7
test/e2e/app-dir/metadata-parallel-routes/app/nested/@bar/page.tsx
This file contains hidden or 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 Page() { | ||
return <div>Bar Slot</div> | ||
} | ||
|
||
export const metadata = { | ||
title: '@bar - page', | ||
} |
7 changes: 7 additions & 0 deletions
7
test/e2e/app-dir/metadata-parallel-routes/app/nested/@bar/subroute/page.tsx
This file contains hidden or 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 Page() { | ||
return <div>Subroute</div> | ||
} | ||
|
||
export const metadata = { | ||
title: 'subroute - page', | ||
} |
11 changes: 11 additions & 0 deletions
11
test/e2e/app-dir/metadata-parallel-routes/app/nested/@foo/default.tsx
This file contains hidden or 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,11 @@ | ||
export default function Default() { | ||
console.log( | ||
'foo default default page', | ||
typeof window !== 'undefined' ? 'client' : 'server' | ||
) | ||
return '@foo default' | ||
} | ||
|
||
export const metadata = { | ||
title: '@foo - default', | ||
} |
8 changes: 8 additions & 0 deletions
8
test/e2e/app-dir/metadata-parallel-routes/app/nested/@foo/layout.tsx
This file contains hidden or 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,8 @@ | ||
export default function Layout({ children }) { | ||
return ( | ||
<div> | ||
<h1>@foo Layout</h1> | ||
<div id="foo-children">{children}</div> | ||
</div> | ||
) | ||
} |
7 changes: 7 additions & 0 deletions
7
test/e2e/app-dir/metadata-parallel-routes/app/nested/@foo/page.tsx
This file contains hidden or 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 Page() { | ||
return <div>Foo Slot</div> | ||
} | ||
|
||
export const metadata = { | ||
title: '@foo - page', | ||
} |
11 changes: 11 additions & 0 deletions
11
test/e2e/app-dir/metadata-parallel-routes/app/nested/default.tsx
This file contains hidden or 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,11 @@ | ||
export default function Page() { | ||
console.log( | ||
'nested default page', | ||
typeof window !== 'undefined' ? 'client' : 'server' | ||
) | ||
return 'nested default page' | ||
} | ||
|
||
export const metadata = { | ||
title: 'nested - default', | ||
} |
10 changes: 10 additions & 0 deletions
10
test/e2e/app-dir/metadata-parallel-routes/app/nested/layout.tsx
This file contains hidden or 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,10 @@ | ||
export default function Layout({ children, bar, foo }) { | ||
return ( | ||
<div> | ||
<h1>Nested Layout</h1> | ||
<div id="nested-children">{children}</div> | ||
<div id="foo-slot">{foo}</div> | ||
<div id="bar-slot">{bar}</div> | ||
</div> | ||
) | ||
} |
7 changes: 7 additions & 0 deletions
7
test/e2e/app-dir/metadata-parallel-routes/app/nested/page.tsx
This file contains hidden or 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 Page() { | ||
return <div>Hello from Nested</div> | ||
} | ||
|
||
export const metadata = { | ||
title: 'nested - page', | ||
} |
This file contains hidden or 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 async function Home() { | ||
return <div>Hello World</div> | ||
} |
22 changes: 22 additions & 0 deletions
22
test/e2e/app-dir/metadata-parallel-routes/metadata-parallel-routes.test.ts
This file contains hidden or 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,22 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
|
||
describe('metadata-parallel-routes', () => { | ||
const { next } = nextTestSetup({ | ||
files: __dirname, | ||
}) | ||
|
||
it('should ignore metadata from default.js in normal route', async () => { | ||
const $ = await next.render$('/') | ||
// When there's no title, parallel routes should not affect it | ||
expect($('title').length).toBe(0) | ||
|
||
// When there's defined title, parallel routes should not affect it | ||
const $nested = await next.render$('/nested') | ||
expect($nested('title').text()).toBe('nested - page') | ||
}) | ||
|
||
it('should ignore metadata from default.js in parallel routes', async () => { | ||
const $ = await next.render$('/nested/subroute') | ||
expect($('title').text()).toBe('subroute - page') | ||
}) | ||
}) |
This file contains hidden or 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,6 @@ | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
const nextConfig = {} | ||
|
||
module.exports = nextConfig |
4 changes: 4 additions & 0 deletions
4
test/e2e/app-dir/parallel-routes-layouts/app/nested/@bar/page.tsx
This file contains hidden or 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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
export default function Page() { | ||
return <div>Bar Slot</div> | ||
} | ||
|
||
export const metadata = { | ||
title: 'nested - page', | ||
} |
4 changes: 4 additions & 0 deletions
4
test/e2e/app-dir/parallel-routes-layouts/app/nested/@bar/subroute/page.tsx
This file contains hidden or 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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
export default function Page() { | ||
return <div>Subroute</div> | ||
} | ||
|
||
export const metadata = { | ||
title: 'subroute - page', | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's possible that the default is the page though right? since the way resolution works is that page gets higher priority, but without a page, default is given priority.
ref:
next.js/packages/next/src/server/app-render/parse-loader-tree.ts
Line 10 in a29bfa2