-
Notifications
You must be signed in to change notification settings - Fork 26k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Override file based images with social images property (#52416)
Metadata API should provide a way to override the filebased metadata images. As usually for child routes, if there's new social images or icons are provided, the ones from parent routes should be overridden / skipped. The `metadata` object export or `generateMetadata` should be able to do that. Sometimes users still add other og info (besides images) to metadata export (both object and `generateMetadata`). I think we should check if they really have returned images property, then decide to override. - For the same level of routes: - If there's no `openGraph.images` in the returned value, merge with file based images - If there's any `openGraph.images` in the returned value, ignore file based ones - For child level of routes: Always override the parent level, ignoring parent level file based images unless they use `generateMetadata` to merge from `resolvingParentMetadata` value, then the parent level's file based ones will present there Closes NEXT-1418
- Loading branch information
Showing
4 changed files
with
125 additions
and
19 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
15 changes: 15 additions & 0 deletions
15
test/e2e/app-dir/metadata/app/opengraph/static/override/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,15 @@ | ||
export default function Page() { | ||
return 'opengraph-static-override' | ||
} | ||
|
||
export const metadata = { | ||
icons: ['https://custom-icon-1.png'], | ||
openGraph: { | ||
title: 'no-og-image', | ||
images: undefined, | ||
}, | ||
twitter: { | ||
title: 'no-tw-image', | ||
images: null, | ||
}, | ||
} |
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