-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(loader_tree): propagate metadata to corresponding layout (#56956)
### What? - fixes test https://github.com/vercel/next.js/blob/17553c5e25c824ce04045066c24a8f138881473d/test/e2e/app-dir/metadata/metadata.test.ts#L487 The way next.js collects static metadata is read static metadata, and then read layout metadata to merge multiple metadatas into a single layout path (https://github.com/vercel/next.js/blob/17553c5e25c824ce04045066c24a8f138881473d/packages/next/src/lib/metadata/resolve-metadata.ts#L347-L352) When turbopack creates LoaderTree for the corresponding directory tree, it extracts `page` but skips metadata in result there are orphan components that have a metadata doesn't have layout metadata, as well as a component have a layout doesn't have metadata. Latter is being rendered as a page (since it have correct layout), which eventually falls back to the default metadata instead. PR trickles down the metadata when extracting page (creating a new component with `page`) to consolidates those. Also PR expands Metadata to have base_page property to capture where it has been originally exists, as we clone down metadata then do `fillMetadataSegment` against the current page where LoaderTree is being created it creates a wrong relative path. For example, currently ``` /icon.svg - opengragph/ - static -> path being `/opengraph/.../icon.svg` instead of `/icon.svg` ``` When recursively traverse directory tree, capture each components with corresponding base_page to calculate instead. Unfortunately this doesn't make pass all of the metadata tests; there are lot to dig more. Would like to scope PR in a reasonable size. Closes WEB-1795
- Loading branch information
Showing
3 changed files
with
97 additions
and
20 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