Skip to content

Commit

Permalink
fix: correct metadata url suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
Netail committed Sep 11, 2024
1 parent 3d303a1 commit cbcff21
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,11 @@ export const metadata = {
height: 600,
},
],
audio: [
{
url: 'https://nextjs.org/audio.mp3', // Must be an absolute URL
},
],
locale: 'en_US',
type: 'website',
},
Expand All @@ -521,9 +526,10 @@ export const metadata = {
<meta property="og:image:width" content="1800" />
<meta property="og:image:height" content="1600" />
<meta property="og:image:alt" content="My custom alt" />
<meta property="og:video:url" content="https://nextjs.org/video.mp4" />
<meta property="og:video" content="https://nextjs.org/video.mp4" />
<meta property="og:video:width" content="800" />
<meta property="og:video:height" content="600" />
<meta property="og:audio" content="https://nextjs.org/audio.mp3" />
<meta property="og:type" content="website" />
```

Expand Down
8 changes: 6 additions & 2 deletions packages/next/src/lib/metadata/generate/meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ function camelToSnake(camelCaseStr: string) {

function getMetaKey(prefix: string, key: string) {
// Use `twitter:image` and `og:image` instead of `twitter:image:url` and `og:image:url`
// to be more compatible as it's a more common format
if ((prefix === 'og:image' || prefix === 'twitter:image') && key === 'url') {
// to be more compatible as it's a more common format.
// `og:video` & `og:audio` do not have a `:url` suffix alias
if (
['og:image', 'twitter:image', 'og:video', 'og:audio'].includes(prefix) &&
key === 'url'
) {
return prefix
}
if (prefix.startsWith('og:') || prefix.startsWith('twitter:')) {
Expand Down

0 comments on commit cbcff21

Please sign in to comment.