Skip to content

Instantly share code, notes, and snippets.

@douglas-henrique
Created May 31, 2023 22:41
Show Gist options
  • Save douglas-henrique/2f7d40874d39b03f97a6f591f8bb4bf3 to your computer and use it in GitHub Desktop.
Save douglas-henrique/2f7d40874d39b03f97a6f591f8bb4bf3 to your computer and use it in GitHub Desktop.
Next JS generateMetadata function to twitter opengraph
export async function generateMetadata(
{ params }: { params: { slug: string } }): Promise<Metadata> {
const data: PostFullProps = await getData(params.slug);
return {
title: 'title of your page',
metadataBase: new URL("YOUR_BASE_URL"),
description: 'page description',
keywords: [],
authors: [{ name: 'YOUR NAME' }],
creator: 'YOUR NAME' ,
publisher: 'YOUR NAME' ,
openGraph: {
images: [''],
description: 'page description',
type: 'article',
url: 'YOUR_BASE_URL' + params.slug,
title: 'title of your page',
},
twitter: {
images: [''],
card: 'summary_large_image',
title: 'title of your page',
description: 'page description',
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment