Skip to content

Instantly share code, notes, and snippets.

@csenio
Last active November 6, 2019 12:58
Show Gist options
  • Save csenio/fdd0a0923a3cbe1cd1125341a3ef13a5 to your computer and use it in GitHub Desktop.
Save csenio/fdd0a0923a3cbe1cd1125341a3ef13a5 to your computer and use it in GitHub Desktop.
export default function Seo({title, description, image, type, structuredData}) {
const {asPath} = useRouter()
const titleTemplate = `${title} | Staiy`
return (
<Head>
{/* <!-- Primary Meta Tags --> */}
<title>titleTemplate</title>
<meta name="title" content={titleTemplate} />
{!!description && <meta name="description" content={description} />}
{/* <!-- Open Graph --> */}
<meta property="og:type" content={type || 'website'} />
<meta property="og:url" content={asPath} />
<meta property="og:title" content={titleTemplate} />
{!!description && <meta property="og:description" content={description} />}
<meta property="og:image" content={image || '/static/images/placeholder/landing.jpg'} />
{/* <!-- Twitter --> */}
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content={asPath} />
<meta property="twitter:title" content={titleTemplate} />
{!!description && <meta property="twitter:description" content={description} />}
<meta property="twitter:image" content={image || '/static/images/placeholder/landing.jpg'} />
{/* <!-- Schema.org / structured data --> */}
{structuredData && (
<script
type="application/ld+json"
dangerouslySetInnerHTML={{__html: JSON.stringify(structuredData)}}
></script>
)}
</Head>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment