import NextImage, { type ImageProps as NextImageProps } from 'next/image'; import type { FC, ReactNode } from 'react'; import { useIntl } from 'react-intl'; import type { Article, Meta as MetaType } from '../../../types'; import { useReadingTime } from '../../../utils/hooks'; import { ButtonLink, Heading, type HeadingLevel, Icon, Link, Figure, Time, } from '../../atoms'; import { MetaList, type MetaItemData } from '../../molecules'; import styles from './summary.module.scss'; export type Cover = Pick; export type SummaryMeta = Pick< MetaType<'article'>, | 'author' | 'commentsCount' | 'cover' | 'dates' | 'thematics' | 'topics' | 'wordsCount' >; export type SummaryProps = Pick & { /** * The post metadata. */ meta: SummaryMeta; /** * The heading level (hn). */ titleLevel?: HeadingLevel; /** * The post url. */ url: string; }; /** * Summary component * * Render a page summary. */ export const Summary: FC = ({ intro, meta, title, titleLevel = 2, url, }) => { const intl = useIntl(); const readMore = intl.formatMessage( { defaultMessage: 'Read more about {title}', description: 'Summary: read more link', id: 'Zpgv+f', }, { title, a11y: (chunks: ReactNode) => ( // eslint-disable-next-line react/jsx-no-literals -- SR class allowed {chunks} ), } ); const readingTime = useReadingTime(meta.wordsCount, true); const getMetaItems = (): MetaItemData[] => { const summaryMeta: MetaItemData[] = [ { id: 'publication-date', label: intl.formatMessage({ defaultMessage: 'Published on:', description: 'Summary: publication date label', id: 'TvQ2Ee', }), value: