-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix favicon merging with customized icons (#67982)
### What Support merging the static metadata file conventions `favicon.ico` with other customized metadata icon from the module export. ### Why `favicon.ico` should be displayed everywhere as it's the icon representative of the website for all pages. Any customized `icon` in metadata export `export const metadata` or `export function generateMetadata()` shouldn't override the `favicon.ico` file convention. Fixes #55767 --------- Co-authored-by: hrmny <[email protected]>
- Loading branch information
1 parent
070159a
commit 9568a4f
Showing
11 changed files
with
171 additions
and
50 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
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
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
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 type StaticMetadata = { | ||
icon: any[] | undefined | ||
apple: any[] | undefined | ||
openGraph: any[] | undefined | ||
twitter: any[] | undefined | ||
manifest: string | undefined | ||
} | null |
Binary file not shown.
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,20 @@ | ||
import { ReactNode } from 'react' | ||
|
||
export default function Root({ children }: { children: ReactNode }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} | ||
|
||
export const metadata = { | ||
icons: { | ||
shortcut: '/shortcut-icon.png', | ||
apple: '/apple-icon.png', | ||
other: { | ||
rel: 'apple-touch-icon-precomposed', | ||
url: '/apple-touch-icon-precomposed.png', | ||
}, | ||
}, | ||
} |
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,14 @@ | ||
export default function Page() { | ||
return <p>hello world</p> | ||
} | ||
|
||
export const metadata = { | ||
icons: { | ||
shortcut: '/shortcut-icon-nested.png', | ||
apple: '/apple-icon-nested.png', | ||
other: { | ||
rel: 'apple-touch-icon-precomposed-nested', | ||
url: '/apple-touch-icon-precomposed-nested.png', | ||
}, | ||
}, | ||
} |
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 <p>hello world</p> | ||
} |
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,31 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
|
||
describe('app-dir - metadata-icons', () => { | ||
const { next } = nextTestSetup({ | ||
files: __dirname, | ||
}) | ||
|
||
it('should only have 1 favicon link in root page', async () => { | ||
const $ = await next.render$('/') | ||
expect($('link[href^="/favicon.ico"]').length).toBe(1) | ||
}) | ||
|
||
it('should only have 1 favicon link in nested page', async () => { | ||
const $ = await next.render$('/nested') | ||
expect($('link[href^="/favicon.ico"]').length).toBe(1) | ||
}) | ||
|
||
it('should render custom icons along with favicon in root page', async () => { | ||
const $ = await next.render$('/') | ||
expect($('link[rel="shortcut icon"]').attr('href')).toBe( | ||
'/shortcut-icon.png' | ||
) | ||
}) | ||
|
||
it('should render custom icons along with favicon in nested page', async () => { | ||
const $ = await next.render$('/nested') | ||
expect($('link[rel="shortcut icon"]').attr('href')).toBe( | ||
'/shortcut-icon-nested.png' | ||
) | ||
}) | ||
}) |
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
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