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

feat: enhance Metadata 'other' API to support property attribute #66996

Open
wants to merge 1 commit into
base: canary
Choose a base branch
from

Conversation

zhangyu1818
Copy link

@zhangyu1818 zhangyu1818 commented Jun 18, 2024

Related Feature Request discussion

#57527

What?

Added array support to the Metadata other API, allowing developers to customize the use of name or property attributes without affecting existing functionality.

Why?

In some cases, developers need to add meta tags with the property attribute, such as:

<>
  <meta property="product:price:amount" content="19.9" />
  <meta property="product:price:currency" content="USD">
</>

or

<meta property="fb:app_id" content="1234567890" />

I couldn't find detailed standard documentation for these attributes online, only some references like Product-Based OG Tag.

Allowing developers to customize the property attribute will provide greater flexibility, and is particularly useful for e-commerce product pages, and currently, the other option only supports the name attribute.

How?

Added an array option to allow developers to customize meta tag attributes without affecting existing functionality.

Current usage will not be affected.

export const metadata: Metadata = {
  other: {
    custom: 'meta',
    custom1: ['meta1', 'meta2'],
  },
}

Additional array object support.

export const metadata: Metadata = {
  other: [
    { name: 'customName', content: 'customName' },
    { property: 'customProperty', content: 'customProperty' },
  ],
}

@zhangyu1818 zhangyu1818 requested review from ismaelrumzan and molebox and removed request for a team June 18, 2024 15:02
@ijjk ijjk added Documentation Related to Next.js' official documentation. tests type: next labels Jun 18, 2024
@ijjk
Copy link
Member

ijjk commented Jun 18, 2024

Allow CI Workflow Run

  • approve CI run for commit: effd7aa

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@@ -54,6 +54,6 @@ export function createDefaultMetadata(): ResolvedMetadata {
bookmarks: null,
category: null,
classification: null,
other: {},
other: [],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
Will the type change from map to array create problems for Next.JS developers' previous code?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will not affect the previous functionality. I have included test cases for the "other" option, which cover both the previous and the new usage methods.

@zhangyu1818 zhangyu1818 changed the title feat: enhance Metadata 'other' API to support array objects feat: enhance Metadata 'other' API to support property attribute Jun 25, 2024
@andypho
Copy link

andypho commented Sep 12, 2024

Any updates on this?

@zhangyu1818
Copy link
Author

@andypho Currently, there are no maintainers to review this PR. If you want to use Facebook metadata, it is already supported in v14.2.8.

@andypho
Copy link

andypho commented Sep 12, 2024

@andypho Currently, there are no maintainers to review this PR. If you want to use Facebook metadata, it is already supported in v14.2.8.

well I need the custom openGraph, I don't think Facebook metadata works in my case :(

<meta property="og:type" content="og:product" /> // Breaks everything
<meta property="product:price:amount" content="19.9" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Related to Next.js' official documentation. tests type: next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants