Skip to content
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

[NEXT-1094] openGraph parent Metadata merging #49316

Closed
1 task done
bfourgeaud opened this issue May 5, 2023 · 1 comment · Fixed by #49343
Closed
1 task done

[NEXT-1094] openGraph parent Metadata merging #49316

bfourgeaud opened this issue May 5, 2023 · 1 comment · Fixed by #49343
Assignees
Labels
Metadata Related to Next.js' Metadata API.

Comments

@bfourgeaud
Copy link

bfourgeaud commented May 5, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Pro
    Binaries:
      Node: 18.12.1
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.4.1
      eslint-config-next: 13.4.1
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

Metadata (metadata, generateMetadata, next/head, head.js)

Link to the code that reproduces this issue

https://github.com/bfourgeaud/metadata-merge-repro

To Reproduce

  1. Clone, Install & start reproduction project
  2. Go to http://localhost:3000
  3. The Metadata Infos are OK, no error
  4. Go to /child page (link on home page)
  5. The error is there

Describe the Bug

Merging of openGraph ResolvedMetadata object into Metadata is throwing an error. Mainly because of images parameter which is not retrieved correctly from parent it seems.
Also url parameter cannot be spread to Metadata and has to be redefined.

export async function generateMetadata(props, parent?: ResolvingMetadata):Promise<Metadata> {
  const parentOpenGraph = (await parent)?.openGraph

  return {
    title: "Child",
    openGraph: {
      ...parentOpenGraph,
      title: "Child",
      url: ""
    }
  }
}

Expected Behavior

It should be possible to merge the parent Metadata (ResolvedMetadata) into the current Metadata. Both objects should be of compatible types.

Which browser are you using? (if relevant)

chrome

How are you deploying your application? (if relevant)

VSCode, Vercel

NEXT-1094

@bfourgeaud bfourgeaud added the bug Issue was opened via the bug report template. label May 5, 2023
@github-actions github-actions bot added the Metadata Related to Next.js' Metadata API. label May 5, 2023
@huozhi huozhi added kind: bug and removed bug Issue was opened via the bug report template. labels May 5, 2023
@huozhi huozhi changed the title openGraph parent Metadata merging [NEXT-1094] openGraph parent Metadata merging May 5, 2023
@huozhi huozhi self-assigned this May 5, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2023

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Metadata Related to Next.js' Metadata API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants