Created
April 22, 2020 05:33
-
-
Save zonayedpca/f636ce4d905e4b70d5aa66e0427c7741 to your computer and use it in GitHub Desktop.
A Sample file
This file contains 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 React from "react" | |
import { useStaticQuery, graphql } from "gatsby" | |
import PropTypes from "prop-types" | |
import Helmet from "react-helmet" | |
function SEO({ description, lang, meta, title, ogImage }) { | |
const { site } = useStaticQuery( | |
graphql` | |
query { | |
site { | |
siteMetadata { | |
title | |
description | |
author | |
siteUrl | |
} | |
} | |
} | |
` | |
) | |
const metaDescription = description || site.siteMetadata.description | |
return ( | |
<Helmet | |
htmlAttributes={{ | |
lang, | |
}} | |
title={title} | |
titleTemplate={`%s | ${site.siteMetadata.title}`} | |
meta={[ | |
{ | |
name: `description`, | |
content: metaDescription, | |
}, | |
{ | |
property: `og:title`, | |
content: title, | |
}, | |
{ | |
property: `og:description`, | |
content: metaDescription, | |
}, | |
{ | |
property: `og:type`, | |
content: `website`, | |
}, | |
{ | |
property: "og:image", | |
content: `${site.siteMetadata.siteUrl}/static/thumbnail/${ogImage}`, | |
}, | |
{ | |
property: "og:image:secure_url", | |
content: `${site.siteMetadata.siteUrl}/static/thumbnail/${ogImage}`, | |
}, | |
{ | |
property: "og:image:width", | |
content: "1200", | |
}, | |
{ | |
property: "og:image:height", | |
content: "630", | |
}, | |
{ | |
name: `twitter:card`, | |
content: `summary_large_image`, | |
}, | |
{ | |
name: `twitter:site`, | |
content: `@gradienta`, | |
}, | |
{ | |
name: `twitter:creator`, | |
content: site.siteMetadata.author, | |
}, | |
{ | |
name: `twitter:title`, | |
content: title, | |
}, | |
{ | |
name: `twitter:description`, | |
content: metaDescription, | |
}, | |
{ | |
name: `twitter:image`, | |
content: `${site.siteMetadata.siteUrl}/static/thumbnail/${ogImage}`, | |
}, | |
].concat(meta)} | |
link={[{ rel: "icon", type: "image/png", href: "favicon.ico" }]} | |
/> | |
) | |
} | |
SEO.defaultProps = { | |
lang: `en`, | |
meta: [], | |
description: ``, | |
ogImage: "thumbnail.jpg", | |
} | |
SEO.propTypes = { | |
description: PropTypes.string, | |
lang: PropTypes.string, | |
meta: PropTypes.arrayOf(PropTypes.object), | |
title: PropTypes.string.isRequired, | |
} | |
export { SEO } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment