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,
|
image,
|
||||||
url,
|
url,
|
||||||
postSEO,
|
postSEO,
|
||||||
title
|
title,
|
||||||
|
datePublished,
|
||||||
|
dateModified
|
||||||
}: {
|
}: {
|
||||||
description: string
|
description: string
|
||||||
image: string
|
image: string
|
||||||
url: string
|
url: string
|
||||||
postSEO: boolean
|
postSEO: boolean
|
||||||
title: string
|
title: string
|
||||||
|
datePublished: string
|
||||||
|
dateModified: string
|
||||||
}) {
|
}) {
|
||||||
const { siteTitle, siteDescription, siteUrl, author } = useSiteMetadata()
|
const { siteTitle, siteDescription, siteUrl, author } = useSiteMetadata()
|
||||||
|
|
||||||
@ -40,7 +44,17 @@ export default function MetaTags({
|
|||||||
<meta name="image" content={image} />
|
<meta name="image" content={image} />
|
||||||
<link rel="canonical" href={url} />
|
<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:title" content={title} />
|
||||||
<meta property="og:description" content={description} />
|
<meta property="og:description" content={description} />
|
||||||
|
@ -60,6 +60,8 @@ export default function SEO({
|
|||||||
url={url}
|
url={url}
|
||||||
postSEO={postSEO}
|
postSEO={postSEO}
|
||||||
title={title}
|
title={title}
|
||||||
|
datePublished={post && post.fields && post.fields.date}
|
||||||
|
dateModified={post && post.frontmatter.updated}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,14 @@ export default function schemaOrg(
|
|||||||
postURL: string,
|
postURL: string,
|
||||||
image: string,
|
image: string,
|
||||||
description: string,
|
description: string,
|
||||||
author?: string
|
author: string,
|
||||||
|
datePublished: string,
|
||||||
|
dateModified: string
|
||||||
) {
|
) {
|
||||||
const schemaOrgJSONLD: any = [
|
const schemaOrgJSONLD: any = [
|
||||||
{
|
{
|
||||||
'@context': 'http://schema.org',
|
'@context': 'http://schema.org',
|
||||||
'@type': 'WebSite',
|
'@type': 'Blog',
|
||||||
url: blogURL,
|
url: blogURL,
|
||||||
name: title
|
name: title
|
||||||
}
|
}
|
||||||
@ -22,8 +24,14 @@ export default function schemaOrg(
|
|||||||
schemaOrgJSONLD.push({
|
schemaOrgJSONLD.push({
|
||||||
'@context': 'http://schema.org',
|
'@context': 'http://schema.org',
|
||||||
'@type': 'BlogPosting',
|
'@type': 'BlogPosting',
|
||||||
author,
|
author: {
|
||||||
publisher: author,
|
'@type': 'Person',
|
||||||
|
name: author
|
||||||
|
},
|
||||||
|
publisher: {
|
||||||
|
'@type': 'Organization',
|
||||||
|
name: author
|
||||||
|
},
|
||||||
url: postURL,
|
url: postURL,
|
||||||
name: title,
|
name: title,
|
||||||
headline: title,
|
headline: title,
|
||||||
@ -31,7 +39,13 @@ export default function schemaOrg(
|
|||||||
'@type': 'ImageObject',
|
'@type': 'ImageObject',
|
||||||
url: image
|
url: image
|
||||||
},
|
},
|
||||||
description
|
description,
|
||||||
|
datePublished,
|
||||||
|
dateModified: dateModified || datePublished,
|
||||||
|
mainEntityOfPage: {
|
||||||
|
'@type': 'Blog',
|
||||||
|
'@id': blogURL
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user