import Head from 'next/head' import { useRouter } from 'next/router' import siteMetadata from '@/data/siteMetadata' import { AuthorFrontMatter } from 'types/AuthorFrontMatter' import { PostFrontMatter } from 'types/PostFrontMatter' interface CommonSEOProps { title: string description: string ogType: string ogImage: | string | { '@type': string url: string }[] twImage: string canonicalUrl?: string } const CommonSEO = ({ title, description, ogType, ogImage, twImage, canonicalUrl, }: CommonSEOProps) => { const router = useRouter() return ( {title} {Array.isArray(ogImage) ? ( ogImage.map(({ url }) => ) ) : ( )} ) } interface PageSEOProps { title: string description: string } export const PageSEO = ({ title, description }: PageSEOProps) => { const ogImageUrl = siteMetadata.siteUrl + siteMetadata.socialBanner const twImageUrl = siteMetadata.siteUrl + siteMetadata.socialBanner return ( ) } export const TagSEO = ({ title, description }: PageSEOProps) => { const ogImageUrl = siteMetadata.siteUrl + siteMetadata.socialBanner const twImageUrl = siteMetadata.siteUrl + siteMetadata.socialBanner const router = useRouter() return ( <> ) } interface BlogSeoProps extends PostFrontMatter { authorDetails?: AuthorFrontMatter[] url: string } export const BlogSEO = ({ authorDetails, title, summary, date, lastmod, url, images = [], canonicalUrl, }: BlogSeoProps) => { const publishedAt = new Date(date).toISOString() const modifiedAt = new Date(lastmod || date).toISOString() const imagesArr = images.length === 0 ? [siteMetadata.socialBanner] : typeof images === 'string' ? [images] : images const featuredImages = imagesArr.map((img) => { return { '@type': 'ImageObject', url: `${siteMetadata.siteUrl}${img}`, } }) 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, } const twImageUrl = featuredImages[0].url return ( <> {date && } {lastmod && }