Next.js Discord

Discord Forum

Nextjs Metadata

Unanswered
Anhinga posted this in #help-forum
Open in Discord
Avatar
AnhingaOP
Hey guys I have everything setup for my metadata but for no reaons they dont want to work in twitter, slack or anywhere else :/
Image

16 Replies

Avatar
AnhingaOP
It should load
Every metadata are correct
Image
Avatar
Image
I am not even getting the UI
can you show me how you set your metadata btw?
Avatar
AnhingaOP
yeah but if you check the metadata should work
export async function generateMetadata({ params: { id, locale } }: { params: { id: string; locale: string } }) {
  const { data: post } = await unauthPlazaClient.posts.getPostById(id, {
    fields: ['title', 'preview', 'creatorId', 'creatorName', 'media', 'comments', 'dollarTips'],
  });

  return createMetadata({
    title: post?.title,
    description: `${post?.preview} | ${new KPrice(post.comments).format(locale, { precision: 0 })} comments | $${new KPrice(post.dollarTips).format(locale)} tips`,
    imageUrl: post?.media,
    creator: post?.creatorName,
    url: `${siteConfig.url}/${locale}/post/${id}`,
  });
}
the createMetadata function
export const createMetadata = ({
  title,
  description,
  creator,
  imageUrl,
  url,
}: {
  title?: string;
  description?: string;
  imageUrl?: string;
  creator?: string;
  url?: string;
}) => {
  return {
    ...DEFAULT_METADATA,
    title,
    description,
    openGraph: {
      ...DEFAULT_METADATA.openGraph,
      title,
      description,
      url,
      images: [{ url: imageUrl, width: 1280, height: 720, alt: 'Cover Image' }],
    },
    twitter: {
      ...DEFAULT_METADATA.twitter,
      title,
      description,
      images: [imageUrl],
      creator,
    },
  };
};
the DEFAULT
export const DEFAULT_METADATA: Metadata = {
  title: {
    default: siteConfig.name,
    template: `%s | ${siteConfig.name}`,
  },
  description: siteConfig.description,
  keywords: [
    'Plazas',
    'Hedera',
    'Kabila Plazas',
    'SocialFi',
    'Tokenized Communities',
    'NFT space',
    'Hedera NFTs',
    'Kabila',
  ],
  authors: [
    {
      name: 'Kabila',
      url: 'https://kabila.app',
    },
  ],
  creator: 'Kabila',
  openGraph: {
    type: 'website',
    locale: 'en_US',
    url: siteConfig.url,
    title: siteConfig.name,
    description: siteConfig.description,
    siteName: siteConfig.name,
    images: [
      {
        url: siteConfig.ogImage,
        width: 1200,
        height: 630,
        alt: siteConfig.name,
      },
    ],
  },
  twitter: {
    card: 'summary_large_image',
    title: siteConfig.name,
    description: siteConfig.description,
    images: [siteConfig.ogImage],
    creator: '@kabilaapp',
  },
  icons: {
    icon: '/favicon.ico',
  },
  metadataBase: new URL(`${siteConfig.url}/`),
  robots: {
    index: true,
    follow: true,
    nocache: true,
    googleBot: {
      index: true,
      follow: false,
      noimageindex: true,
      'max-video-preview': -1,
      'max-image-preview': 'large',
      'max-snippet': -1,
    },
  },
};
If you can help me, thanks you so much