From 5f49e5e083580cd92deee94e424515e0330559ef Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 25 Nov 2019 21:51:18 +0100 Subject: [PATCH] put back schema.org meta tags --- src/components/atoms/SEO.tsx | 98 ++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/src/components/atoms/SEO.tsx b/src/components/atoms/SEO.tsx index 10bffcd4..ab988baf 100644 --- a/src/components/atoms/SEO.tsx +++ b/src/components/atoms/SEO.tsx @@ -16,55 +16,55 @@ const query = graphql` } ` -// const createSchemaOrg = ( -// blogURL: string, -// title: string, -// postSEO: boolean, -// postURL: string, -// image: string, -// description: string, -// author?: string -// ) => { -// const schemaOrgJSONLD: any = [ -// { -// '@context': 'http://schema.org', -// '@type': 'WebSite', -// url: blogURL, -// name: title -// } -// ] +const createSchemaOrg = ( + blogURL: string, + title: string, + postSEO: boolean, + postURL: string, + image: string, + description: string, + author?: string +) => { + const schemaOrgJSONLD: any = [ + { + '@context': 'http://schema.org', + '@type': 'WebSite', + url: blogURL, + name: title + } + ] -// if (postSEO) { -// schemaOrgJSONLD.push({ -// '@context': 'http://schema.org', -// '@type': 'BlogPosting', -// author, -// publisher: author, -// url: postURL, -// name: title, -// headline: title, -// image: { -// '@type': 'ImageObject', -// url: image -// }, -// description -// }) -// } -// return schemaOrgJSONLD -// } + if (postSEO) { + schemaOrgJSONLD.push({ + '@context': 'http://schema.org', + '@type': 'BlogPosting', + author, + publisher: author, + url: postURL, + name: title, + headline: title, + image: { + '@type': 'ImageObject', + url: image + }, + description + }) + } + return schemaOrgJSONLD +} const MetaTags = ({ description, image, url, - // schema, + schema, postSEO, title }: { description: string image: string url: string - // schema: string + schema: string postSEO: boolean title: string }) => { @@ -83,7 +83,7 @@ const MetaTags = ({ {/* Schema.org tags */} - {/* */} + {/* OpenGraph tags */} @@ -123,7 +123,7 @@ export default function SEO({ }) { const data = useStaticQuery(query) const logo = data.logo.edges[0].node.relativePath - const { siteTitle, siteUrl, siteDescription } = useSiteMetadata() + const { siteTitle, siteUrl, siteDescription, author } = useSiteMetadata() let title let description @@ -148,22 +148,22 @@ export default function SEO({ const blogURL = siteUrl const url = postSEO ? postURL : blogURL - // const schema = createSchemaOrg( - // blogURL, - // title, - // postSEO, - // postURL, - // image, - // description, - // author - // ) + const schema = createSchemaOrg( + blogURL, + title, + postSEO, + postURL, + image, + description, + author.name + ) return (