Skip to content

Commit

Permalink
Fix og/twitter image
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalp committed Jul 18, 2019
1 parent 08f6c7a commit 4776fbf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
siteMetadata: {
title: `GraphQL Wroclaw`,
description: `GraphQL Wroclaw has rapidly grown into a thriving community. Regular Meetup events are a chance to exchange knowledge and experience with our peers. People. Talks. Technology.`,
image: "/images/og-image.png",
siteUrl: "https://graphqlwroclaw.org",
author: `@mirumee`,
},
plugins: [
Expand Down
20 changes: 19 additions & 1 deletion src/components/seo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,28 @@ import Helmet from "react-helmet"
import { useStaticQuery, graphql } from "gatsby"

function SEO({ description, lang, meta, keywords, title }) {
const { site } = useStaticQuery(
const {
site,
file: { publicURL: imageURL },
} = useStaticQuery(
graphql`
query {
site {
siteMetadata {
title
description
author
siteUrl
}
}
file(name: { eq: "og-image" }) {
publicURL
}
}
`
)

const { siteUrl } = site.siteMetadata
const metaDescription = description || site.siteMetadata.description

return (
Expand All @@ -40,6 +48,10 @@ function SEO({ description, lang, meta, keywords, title }) {
property: `og:description`,
content: metaDescription,
},
{
property: `og:image`,
content: `${siteUrl}${imageURL}`,
},
{
property: `og:type`,
content: `website`,
Expand All @@ -60,6 +72,10 @@ function SEO({ description, lang, meta, keywords, title }) {
name: `twitter:description`,
content: metaDescription,
},
{
name: `titter:image`,
content: `${siteUrl}${imageURL}`,
},
]
.concat(
keywords.length > 0
Expand All @@ -79,10 +95,12 @@ SEO.defaultProps = {
meta: [],
keywords: [],
description: ``,
image: null,
}

SEO.propTypes = {
description: PropTypes.string,
image: PropTypes.string,
lang: PropTypes.string,
meta: PropTypes.arrayOf(PropTypes.object),
keywords: PropTypes.arrayOf(PropTypes.string),
Expand Down

0 comments on commit 4776fbf

Please sign in to comment.