Use authorDetails to pull JSON-LD authors names

This commit is contained in:
Ahmad Al Maaz 2021-06-26 14:35:27 +03:00
parent 8d16a0c255
commit e92b7d2737
2 changed files with 8 additions and 5 deletions

View File

@ -24,7 +24,7 @@ export const PageSeo = ({ title, description }) => {
) )
} }
export const BlogSeo = ({ authors = [], title, summary, date, lastmod, url, 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()
@ -42,11 +42,10 @@ export const BlogSeo = ({ authors = [], title, summary, date, lastmod, url, imag
} }
}) })
let authorsArr = authors.length === 0 ? [siteMetadata.author] : authors const authorList = authorDetails.map((author) => {
const authorList = authorsArr.map((author) => {
return { return {
'@type': 'Person', '@type': 'Person',
name: author, name: author.name,
} }
}) })

View File

@ -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">