-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
235 additions
and
24 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
import React from "react" | ||
import Helmet from "react-helmet" | ||
|
||
export default React.memo( | ||
({ | ||
author, | ||
canonicalUrl, | ||
datePublished, | ||
defaultTitle, | ||
description, | ||
image, | ||
logo, | ||
isBlogPost, | ||
organization, | ||
title, | ||
url, | ||
}) => { | ||
const baseSchema = [ | ||
{ | ||
"@context": "http://schema.org", | ||
"@type": "ProfessionalService", | ||
"@id": "https://rupssmokehousejerky.com/", | ||
name: "Rup's Smokehouse Jerky", | ||
alternateName: "Rup's Smokehouse Jerky", | ||
logo: logo, | ||
telephone: "", | ||
email: "", | ||
sameAs: [], | ||
url: "https://rupssmokehousejerky.com/", | ||
image: image, | ||
priceRange: "$$", | ||
description: description, | ||
address: { | ||
"@type": "PostalAddress", | ||
streetAddress: "", | ||
addressLocality: "", | ||
addressRegion: "", | ||
postalCode: "", | ||
addressCountry: "CA", | ||
}, | ||
openingHoursSpecification: [ | ||
{ | ||
"@type": "OpeningHoursSpecification", | ||
dayOfWeek: ["Monday"], | ||
opens: "", | ||
closes: "", | ||
}, | ||
{ | ||
"@type": "OpeningHoursSpecification", | ||
dayOfWeek: ["Tuesday"], | ||
opens: "", | ||
closes: "", | ||
}, | ||
{ | ||
"@type": "OpeningHoursSpecification", | ||
dayOfWeek: ["Wednesday"], | ||
opens: "", | ||
closes: "", | ||
}, | ||
{ | ||
"@type": "OpeningHoursSpecification", | ||
dayOfWeek: ["Thursday"], | ||
opens: "", | ||
closes: "", | ||
}, | ||
{ | ||
"@type": "OpeningHoursSpecification", | ||
dayOfWeek: ["Friday"], | ||
opens: "", | ||
closes: "", | ||
}, | ||
{ | ||
"@type": "OpeningHoursSpecification", | ||
dayOfWeek: ["Saturday"], | ||
opens: "", | ||
closes: "", | ||
}, | ||
{ | ||
"@type": "OpeningHoursSpecification", | ||
dayOfWeek: ["Sunday"], | ||
opens: "", | ||
closes: "", | ||
}, | ||
], | ||
}, | ||
] | ||
|
||
const schema = isBlogPost | ||
? [ | ||
...baseSchema, | ||
{ | ||
"@context": "http://schema.org", | ||
"@type": "BreadcrumbList", | ||
itemListElement: [ | ||
{ | ||
"@type": "ListItem", | ||
position: 1, | ||
item: { | ||
"@id": url, | ||
name: title, | ||
image, | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
"@context": "http://schema.org", | ||
"@type": "BlogPosting", | ||
url, | ||
name: title, | ||
alternateName: defaultTitle, | ||
headline: title, | ||
image: { | ||
"@type": "ImageObject", | ||
url: image, | ||
}, | ||
description, | ||
author: { | ||
"@type": "Person", | ||
name: author.name, | ||
}, | ||
publisher: { | ||
"@type": "Organization", | ||
url: organization.url, | ||
logo: organization.logo, | ||
name: organization.name, | ||
}, | ||
mainEntityOfPage: { | ||
"@type": "WebSite", | ||
"@id": canonicalUrl, | ||
}, | ||
datePublished, | ||
}, | ||
] | ||
: baseSchema | ||
|
||
return ( | ||
<Helmet> | ||
{/* Schema.org tags */} | ||
<script type="application/ld+json">{JSON.stringify(schema)}</script> | ||
</Helmet> | ||
) | ||
} | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,112 @@ | ||
/** | ||
* SEO component that queries for data with | ||
* Gatsby's useStaticQuery React hook | ||
* | ||
* See: https://www.gatsbyjs.com/docs/how-to/querying-data/use-static-query/ | ||
*/ | ||
|
||
import * as React from "react" | ||
import React from "react" | ||
import PropTypes from "prop-types" | ||
import Helmet from "react-helmet" | ||
import { useStaticQuery, graphql } from "gatsby" | ||
import SchemaOrg from "./SchemaOrg" | ||
|
||
function Seo({ description, title, children }) { | ||
const { site } = useStaticQuery( | ||
function Seo({ description, lang, meta, title, metaImg, location }) { | ||
const { site, siteLogo, defaultFb } = useStaticQuery( | ||
graphql` | ||
query { | ||
site { | ||
siteMetadata { | ||
title | ||
description | ||
author | ||
siteLogo | ||
metaImg | ||
siteUrl | ||
} | ||
} | ||
siteLogo: file(relativePath: { eq: "rups-logo-rups.png" }) { | ||
publicURL | ||
} | ||
defaultFb: file(relativePath: { eq: "rups-logo-rups.png" }) { | ||
publicURL | ||
} | ||
} | ||
` | ||
) | ||
|
||
const isBlogPost = false | ||
const siteLogoUrl = `${site.siteMetadata.siteUrl}/${siteLogo.publicURL}` | ||
const metaDescription = description || site.siteMetadata.description | ||
const defaultTitle = site.siteMetadata?.title | ||
|
||
const backupDefaultFBImgUrl = defaultFb.publicURL | ||
const pageSpecificityFBImgUrl = metaImg | ||
const imgToUse = | ||
pageSpecificityFBImgUrl !== null | ||
? pageSpecificityFBImgUrl | ||
: `${site.siteMetadata.siteUrl}/${backupDefaultFBImgUrl}` | ||
const canonicalUrl = `${site.siteMetadata.siteUrl}${location}` | ||
|
||
return ( | ||
<> | ||
<title>{defaultTitle ? `${title} | ${defaultTitle}` : title}</title> | ||
<meta name="description" content={metaDescription} /> | ||
<meta property="og:title" content={title} /> | ||
<meta property="og:description" content={metaDescription} /> | ||
<meta property="og:type" content="website" /> | ||
<meta name="twitter:card" content="summary" /> | ||
<meta name="twitter:creator" content={site.siteMetadata?.author || ``} /> | ||
<meta name="twitter:title" content={title} /> | ||
<meta name="twitter:description" content={metaDescription} /> | ||
{children} | ||
</> | ||
<React.Fragment> | ||
<Helmet htmlAttributes={{ lang }}> | ||
{/* General tags */} | ||
<title>{title}</title> | ||
<meta charset="UTF-8" /> | ||
<meta name="HandheldFriendly" content="true" /> | ||
<meta name="description" content={metaDescription} /> | ||
<meta name="image" content={imgToUse} /> | ||
<link rel="canonical" href={canonicalUrl} /> | ||
|
||
{/* OpenGraph tags */} | ||
<meta property="og:url" content={canonicalUrl} /> | ||
{isBlogPost ? ( | ||
<meta property="og:type" content="article" /> | ||
) : ( | ||
<meta property="og:type" content="website" /> | ||
)} | ||
<meta property="og:title" content={title} /> | ||
<meta property="og:description" content={metaDescription} /> | ||
<meta property="og:image" content={imgToUse} /> | ||
<meta property="og:image:alt" content={metaDescription} /> | ||
{/* <meta property="fb:app_id" content={seo.social.fbAppID} /> */} | ||
<meta property="og:site_name" content={title} /> | ||
<meta property="og:locale" content={`en_US`} /> | ||
{/* Twitter Card tags */} | ||
<meta name="twitter:card" content="summary_large_image" /> | ||
<meta name="twitter:creator" content={site.siteMetadata.author} /> | ||
<meta name="twitter:title" content={title} /> | ||
<meta name="twitter:description" content={metaDescription} /> | ||
<meta name="twitter:image" content={imgToUse} /> | ||
{/* Google Ownership Verification */} | ||
{/* <meta | ||
name="google-site-verification" | ||
content="" | ||
/> */} | ||
</Helmet> | ||
|
||
<SchemaOrg | ||
isBlogPost={false} | ||
url={site.siteMetadata.siteUrl} | ||
title={title} | ||
image={siteLogoUrl} | ||
logo={siteLogoUrl} | ||
description={description} | ||
datePublished="June 28, 2023" | ||
canonicalUrl="http://rupssmokehousejerky.com/" | ||
author="@switchback4ever" | ||
organization="Rup's Smokehouse Jerky" | ||
defaultTitle="Rup's Smokehouse Jerky" | ||
/> | ||
</React.Fragment> | ||
) | ||
} | ||
|
||
Seo.defaultProps = { | ||
lang: `en`, | ||
meta: [], | ||
description: ``, | ||
} | ||
|
||
Seo.propTypes = { | ||
description: PropTypes.string, | ||
lang: PropTypes.string, | ||
meta: PropTypes.arrayOf(PropTypes.object), | ||
title: PropTypes.string.isRequired, | ||
} | ||
|
||
export default Seo |