import { ButtonLink } from '@components/Buttons'; import { ArrowIcon } from '@components/Icons'; import PostMeta from '@components/PostMeta/PostMeta'; import { config } from '@config/website'; import { TitleLevel } from '@ts/types/app'; import { ArticleMeta, ArticlePreview } from '@ts/types/articles'; import Image from 'next/image'; import Head from 'next/head'; import Link from 'next/link'; import { FormattedMessage } from 'react-intl'; import { BlogPosting, WithContext } from 'schema-dts'; import styles from './PostPreview.module.scss'; const PostPreview = ({ post, titleLevel, }: { post: ArticlePreview; titleLevel: TitleLevel; }) => { const TitleTag = `h${titleLevel}` as keyof JSX.IntrinsicElements; const { commentCount, dates, featuredImage, info, intro, slug, thematics, title, topics, } = post; const meta: ArticleMeta = { commentCount: commentCount ? commentCount : 0, dates: dates, readingTime: info.readingTime, thematics: thematics, topics: topics, wordsCount: info.wordsCount, }; const publicationDate = new Date(dates.publication); const updateDate = new Date(dates.update); const schemaJsonLd: WithContext = { '@context': 'https://schema.org', '@type': 'BlogPosting', name: title, description: intro, articleBody: intro, author: { '@id': `${config.url}/#branding` }, commentCount: commentCount ? 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: featuredImage?.sourceUrl, inLanguage: config.locales.defaultLocale, isBasedOn: `${config.url}/article/${slug}`, isPartOf: { '@id': `${config.url}/blog` }, license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr', thumbnailUrl: featuredImage?.sourceUrl, }; return ( <>
{featuredImage && Object.keys(featuredImage).length > 0 && (
{featuredImage.altText}
)}
{title}
( {chunks} ), }} />
); }; export default PostPreview;