Created
June 6, 2012 20:21
-
-
Save McKinneyDigital/2884508 to your computer and use it in GitHub Desktop.
Share to Twitter from a link using Javascript
How can we share image?
You can only share image through metadata i guess, that's the only way i have been able to figure out.
for example in NextJs
const article = {
title: "Hello me",
description: "this is a test for descripton",
imageUrl:
"https://media.npr.org/assets/img/2018/04/20/gettyimages-495019617_wide-70695696742f3348b675ebf762df2f3b8256f1dd.jpg?s=1100&c=85&f=jpeg",
slug: "test-me",
content: "HEY BROOOOO",
};
export async function generateMetadata() {
// Assuming `params.slug` matches the article's slug
return {
title: article.title,
description: article.description,
twitter: {
card: "summary_large_image",
title: article.title,
description: article.description,
images: [article.imageUrl],
},
};
}
... Rest of the component
If anyone finds a way to share , without metadata, I'd be happy to hear it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can we close the window after posting the link?