Next.js Discord

Discord Forum

generateMetadata not working

Answered
Lukas posted this in #help-forum
Open in Discord
Avatar
I'm working on a website using generateMetadata(), but it doesn't seem to work on discord (https://rovemc.org/blog/b0e9b1f8-54ac-4858-b8a2-b914b71b2900) or [on twitter](https://twitter.com/quick007YT/status/1675236093443317760).

Using heymeta (metadata checker) it displays what I assume it should: https://www.heymeta.com/url/rovemc.org/blog/b0e9b1f8-54ac-4858-b8a2-b914b71b2900

Here's my code:
  const title = postInfo.properties.title.title[0].plain_text;

  const description = `An article from Amethyst Realms. Posted ${formatDate(
     /* @ts-expect-error Mistyped JSON*/
    new Date(postInfo.created_time)
  )}`;

  /* @ts-expect-error Mistyped JSON*/
  const banner = postInfo.cover
   /* @ts-expect-error Mistyped JSON*/
    ? postInfo.cover[postInfo.cover.type].url
    : "https://rove-website.vercel.app/logos/amethyst-banner.png";

  return {
    title,
    description,
    openGraph: {
      title,
      description,
      url: "https://rovemc.org/stats",
      siteName: "Amethyst Realms",
      images: [
        {
          url: banner,
        },
      ],
      locale: "en_US",
      type: "website",
    },
    twitter: {
      card: "summary_large_image",
      title,
      description,
      images: [
        {
          url: banner,
        },
      ],
    },
  };
}


Is this a bug or am I doing something wrong?
Answered by Lukas
This is weird, it's working now
View full answer

3 Replies

Avatar
This is weird, it's working now
Answer
Avatar
There's also a weird bug where if you navigate between routes it won't always update the metadata correctly
Avatar
Looks like a bug could you submit a bug report