Created
November 4, 2020 09:10
-
-
Save dipeshhkc/053734d88aa9406d44a971849bfd6a2f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Head from 'next/head'; | |
import React from 'react'; | |
const Home=({photo})=> { | |
return ( | |
<div> | |
<Head> | |
<title>Social Media Preview</title> | |
<meta property="og:url" content="your url" /> | |
<meta property="og:type" content="website" /> | |
<meta property="fb:app_id" content="your fb id" /> | |
<meta property="og:title" content={photo?.title} /> | |
<meta name="twitter:card" content="summary" /> | |
<meta | |
property="og:description" | |
content="Hurray!! Yes Social Media Preview is Working" | |
/> | |
<meta property="og:image" content={photo?.url} /> | |
</Head> | |
<h2>{photo?.title}</h2> | |
</div> | |
); | |
} | |
export default Home | |
export const getServerSideProps = async () => { | |
let photo = null; | |
await fetch('https://jsonplaceholder.typicode.com/photos/1') | |
.then((response) => response.json()) | |
.then((json) =>{ | |
photo=json | |
}) | |
return { | |
props: { | |
photo, | |
}, | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment