import { type ForwardRefRenderFunction, forwardRef, type ReactNode, } from 'react'; import { useIntl } from 'react-intl'; import type { PageLink } from '../../../types'; import { getReadingTimeFrom } from '../../../utils/helpers'; import { Header, Heading, type HeaderProps, Link, Time } from '../../atoms'; import { MetaList, MetaItem } from '../../molecules'; import styles from './page.module.scss'; export type PageHeaderMetaData = { author: string; publicationDate: string; thematics: PageLink[]; total: number; updateDate: string; website: string; wordsCount: number; }; export type PageHeaderProps = Omit & { /** * The page main title. */ heading: ReactNode; /** * The page introduction. */ intro?: ReactNode; /** * The page meta. */ meta?: Partial; }; const PageHeaderWithRef: ForwardRefRenderFunction< HTMLElement, PageHeaderProps > = ({ className = '', heading, intro, meta, ...props }, ref) => { const headerClass = `${styles.header} ${className}`; const intl = useIntl(); return (
{heading} {meta ? ( {meta.author ? ( ) : null} {meta.publicationDate ? ( } /> ) : null} {meta.updateDate && meta.updateDate !== meta.publicationDate ? ( } /> ) : null} {meta.wordsCount ? ( ) : null} {meta.thematics ? ( { return { id: `thematic-${thematic.id}`, value: {thematic.name}, }; })} /> ) : null} {meta.total ? ( ) : null} {meta.website ? ( {meta.website}} /> ) : null} ) : null} {typeof intro === 'string' ? ( // eslint-disable-next-line react/no-danger -- Intro can contain tags.
) : ( intro )}
); }; export const PageHeader = forwardRef(PageHeaderWithRef);