upstream #1
@ -24,7 +24,7 @@ export const PageSeo = ({ title, description }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const BlogSeo = ({ title, summary, date, lastmod, images = [] }) => {
|
export const BlogSeo = ({ authorDetails, title, summary, date, lastmod, url, images = [] }) => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const publishedAt = new Date(date).toISOString()
|
const publishedAt = new Date(date).toISOString()
|
||||||
const modifiedAt = new Date(lastmod || date).toISOString()
|
const modifiedAt = new Date(lastmod || date).toISOString()
|
||||||
@ -37,11 +37,49 @@ export const BlogSeo = ({ title, summary, date, lastmod, images = [] }) => {
|
|||||||
|
|
||||||
const featuredImages = imagesArr.map((img) => {
|
const featuredImages = imagesArr.map((img) => {
|
||||||
return {
|
return {
|
||||||
|
'@type': 'ImageObject',
|
||||||
url: `${siteMetadata.siteUrl}${img}`,
|
url: `${siteMetadata.siteUrl}${img}`,
|
||||||
alt: title,
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let authorList
|
||||||
|
if (authorDetails) {
|
||||||
|
authorList = authorDetails.map((author) => {
|
||||||
|
return {
|
||||||
|
'@type': 'Person',
|
||||||
|
name: author.name,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
authorList = {
|
||||||
|
'@type': 'Person',
|
||||||
|
name: siteMetadata.author,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const structuredData = {
|
||||||
|
'@context': 'https://schema.org',
|
||||||
|
'@type': 'Article',
|
||||||
|
mainEntityOfPage: {
|
||||||
|
'@type': 'WebPage',
|
||||||
|
'@id': url,
|
||||||
|
},
|
||||||
|
headline: title,
|
||||||
|
image: featuredImages,
|
||||||
|
datePublished: publishedAt,
|
||||||
|
dateModified: modifiedAt,
|
||||||
|
author: authorList,
|
||||||
|
publisher: {
|
||||||
|
'@type': 'Organization',
|
||||||
|
name: siteMetadata.author,
|
||||||
|
logo: {
|
||||||
|
'@type': 'ImageObject',
|
||||||
|
url: `${siteMetadata.siteUrl}${siteMetadata.siteLogo}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: summary,
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
@ -64,6 +102,10 @@ export const BlogSeo = ({ title, summary, date, lastmod, images = [] }) => {
|
|||||||
{date && <meta property="article:published_time" content={publishedAt} />}
|
{date && <meta property="article:published_time" content={publishedAt} />}
|
||||||
{lastmod && <meta property="article:modified_time" content={modifiedAt} />}
|
{lastmod && <meta property="article:modified_time" content={modifiedAt} />}
|
||||||
<link rel="canonical" href={`${siteMetadata.siteUrl}${router.asPath}`} />
|
<link rel="canonical" href={`${siteMetadata.siteUrl}${router.asPath}`} />
|
||||||
|
<script
|
||||||
|
type="application/ld+json"
|
||||||
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(structuredData, null, 2) }}
|
||||||
|
/>
|
||||||
</Head>
|
</Head>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"language": "en-us",
|
"language": "en-us",
|
||||||
"siteUrl": "https://tailwind-nextjs-starter-blog.vercel.app",
|
"siteUrl": "https://tailwind-nextjs-starter-blog.vercel.app",
|
||||||
"siteRepo": "https://github.com/timlrx/tailwind-nextjs-starter-blog",
|
"siteRepo": "https://github.com/timlrx/tailwind-nextjs-starter-blog",
|
||||||
|
"siteLogo": "/static/images/logo.png",
|
||||||
"image": "/static/images/avatar.png",
|
"image": "/static/images/avatar.png",
|
||||||
"socialBanner": "/static/images/twitter-card.png",
|
"socialBanner": "/static/images/twitter-card.png",
|
||||||
"email": "address@yoursite.com",
|
"email": "address@yoursite.com",
|
||||||
|
@ -19,7 +19,11 @@ export default function PostLayout({ frontMatter, authorDetails, next, prev, chi
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<SectionContainer>
|
<SectionContainer>
|
||||||
<BlogSeo url={`${siteMetadata.siteUrl}/blog/${slug}`} {...frontMatter} />
|
<BlogSeo
|
||||||
|
url={`${siteMetadata.siteUrl}/blog/${slug}`}
|
||||||
|
authorDetails={authorDetails}
|
||||||
|
{...frontMatter}
|
||||||
|
/>
|
||||||
<article>
|
<article>
|
||||||
<div className="xl:divide-y xl:divide-gray-200 xl:dark:divide-gray-700">
|
<div className="xl:divide-y xl:divide-gray-200 xl:dark:divide-gray-700">
|
||||||
<header className="pt-6 xl:pb-6">
|
<header className="pt-6 xl:pb-6">
|
||||||
|
BIN
public/static/images/logo.png
Normal file
BIN
public/static/images/logo.png
Normal file
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 42 KiB |
Loading…
x
Reference in New Issue
Block a user