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

Use og:image instead of og:image:url #46570

Merged
merged 3 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/next/src/lib/metadata/generate/meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ function ExtendMeta({
<Meta
key={keyPrefix + ':' + k + '_' + index}
{...(propertyPrefix
? { property: propertyPrefix + ':' + k }
? // Use `og:image` instead of `og:image:url` to be more compatible as it's a more common format
{
property:
propertyPrefix === 'og:image' && k === 'url'
? 'og:image'
: propertyPrefix + ':' + k,
}
: { name: namePrefix + ':' + k })}
content={typeof v === 'string' ? v : v?.toString()}
/>
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/app-dir/metadata/metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ createNextDescribe(
)
await checkMetaPropertyContentPair(browser, 'og:locale', 'en-US')
await checkMetaPropertyContentPair(browser, 'og:type', 'website')
await checkMetaPropertyContentPair(browser, 'og:image:url', [
await checkMetaPropertyContentPair(browser, 'og:image', [
'https://example.com/image.png',
'https://example.com/image2.png',
])
Expand Down Expand Up @@ -464,7 +464,7 @@ createNextDescribe(

it('should pick up opengraph-image and twitter-image as static metadata files', async () => {
const $ = await next.render$('/opengraph/static')
expect($('[property="og:image:url"]').attr('content')).toMatch(
expect($('[property="og:image"]').attr('content')).toMatch(
/https:\/\/example.com\/_next\/static\/media\/metadata\/opengraph-image.\w+.png/
)
expect($('[property="og:image:type"]').attr('content')).toBe(
Expand Down