mirror of
https://github.com/kremalicious/blog.git
synced 2024-12-22 09:13:35 +01:00
add datePublished & dateModified to schema.org tags
This commit is contained in:
parent
36f18bd562
commit
e4300dceb3
@ -19,13 +19,17 @@ export default function MetaTags({
|
||||
image,
|
||||
url,
|
||||
postSEO,
|
||||
title
|
||||
title,
|
||||
datePublished,
|
||||
dateModified
|
||||
}: {
|
||||
description: string
|
||||
image: string
|
||||
url: string
|
||||
postSEO: boolean
|
||||
title: string
|
||||
datePublished: string
|
||||
dateModified: string
|
||||
}) {
|
||||
const { siteTitle, siteDescription, siteUrl, author } = useSiteMetadata()
|
||||
|
||||
@ -40,7 +44,17 @@ export default function MetaTags({
|
||||
<meta name="image" content={image} />
|
||||
<link rel="canonical" href={url} />
|
||||
|
||||
{schemaOrg(siteUrl, title, postSEO, url, image, description, author.name)}
|
||||
{schemaOrg(
|
||||
siteUrl,
|
||||
title,
|
||||
postSEO,
|
||||
url,
|
||||
image,
|
||||
description,
|
||||
author.name,
|
||||
datePublished,
|
||||
dateModified
|
||||
)}
|
||||
|
||||
<meta property="og:title" content={title} />
|
||||
<meta property="og:description" content={description} />
|
||||
|
@ -60,6 +60,8 @@ export default function SEO({
|
||||
url={url}
|
||||
postSEO={postSEO}
|
||||
title={title}
|
||||
datePublished={post && post.fields && post.fields.date}
|
||||
dateModified={post && post.frontmatter.updated}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
@ -7,12 +7,14 @@ export default function schemaOrg(
|
||||
postURL: string,
|
||||
image: string,
|
||||
description: string,
|
||||
author?: string
|
||||
author: string,
|
||||
datePublished: string,
|
||||
dateModified: string
|
||||
) {
|
||||
const schemaOrgJSONLD: any = [
|
||||
{
|
||||
'@context': 'http://schema.org',
|
||||
'@type': 'WebSite',
|
||||
'@type': 'Blog',
|
||||
url: blogURL,
|
||||
name: title
|
||||
}
|
||||
@ -22,8 +24,14 @@ export default function schemaOrg(
|
||||
schemaOrgJSONLD.push({
|
||||
'@context': 'http://schema.org',
|
||||
'@type': 'BlogPosting',
|
||||
author,
|
||||
publisher: author,
|
||||
author: {
|
||||
'@type': 'Person',
|
||||
name: author
|
||||
},
|
||||
publisher: {
|
||||
'@type': 'Organization',
|
||||
name: author
|
||||
},
|
||||
url: postURL,
|
||||
name: title,
|
||||
headline: title,
|
||||
@ -31,7 +39,13 @@ export default function schemaOrg(
|
||||
'@type': 'ImageObject',
|
||||
url: image
|
||||
},
|
||||
description
|
||||
description,
|
||||
datePublished,
|
||||
dateModified: dateModified || datePublished,
|
||||
mainEntityOfPage: {
|
||||
'@type': 'Blog',
|
||||
'@id': blogURL
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user