import PostMeta from '@components/PostMeta/PostMeta'; import { t } from '@lingui/macro'; import { ArticleMeta, ArticlePreview } from '@ts/types/articles'; import Link from 'next/link'; import styles from './PostPreview.module.scss'; import Image from 'next/image'; import { ButtonLink } from '@components/Buttons'; import { ArrowIcon } from '@components/Icons'; import { TitleLevel } from '@ts/types/app'; import { BlogPosting, WithContext } from 'schema-dts'; import Head from 'next/head'; import { config } from '@config/website'; const PostPreview = ({ post, titleLevel, }: { post: ArticlePreview; titleLevel: TitleLevel; }) => { const TitleTag = `h${titleLevel}` as keyof JSX.IntrinsicElements; const meta: ArticleMeta = { commentCount: post.commentCount ? post.commentCount : 0, dates: post.dates, subjects: post.subjects, thematics: post.thematics, }; const publicationDate = new Date(post.dates.publication); const updateDate = new Date(post.dates.update); const schemaJsonLd: WithContext = { '@context': 'https://schema.org', '@type': 'BlogPosting', name: post.title, description: post.intro, articleBody: post.intro, author: { '@id': `${config.url}/#branding` }, commentCount: post.commentCount ? post.commentCount : 0, copyrightYear: publicationDate.getFullYear(), creator: { '@id': `${config.url}/#branding` }, dateCreated: publicationDate.toISOString(), dateModified: updateDate.toISOString(), datePublished: publicationDate.toISOString(), editor: { '@id': `${config.url}/#branding` }, image: post.featuredImage?.sourceUrl, inLanguage: config.locales.defaultLocale, isBasedOn: `${config.url}/article/${post.slug}`, isPartOf: { '@id': `${config.url}/blog` }, license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr', thumbnailUrl: post.featuredImage?.sourceUrl, }; return ( <>
{post.featuredImage && Object.keys(post.featuredImage).length > 0 && (
{post.featuredImage.altText}
)}
{post.title}
{t`Read more`} {' '} {t({ message: `about ${post.title}`, comment: 'Post title' })}
); }; export default PostPreview;