diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-05-09 18:19:38 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-05-09 19:41:02 +0200 |
| commit | 0d59a6d2995b4119865271ed1908ede0bb96497c (patch) | |
| tree | 67688e41b7aa253aa58cc08aa360431b07382f9d /src/components/organisms/layout/summary.tsx | |
| parent | 339c6957fe92c4ec1809159f09c55201d3794c18 (diff) | |
refactor: rewrite DescriptionList and Meta components
The meta can have different layout. The previous implementation was not
enough to easily change the layout. Also, I prefer to restrict the meta
types and it prevents me to repeat myself for the labels.
Diffstat (limited to 'src/components/organisms/layout/summary.tsx')
| -rw-r--r-- | src/components/organisms/layout/summary.tsx | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/src/components/organisms/layout/summary.tsx b/src/components/organisms/layout/summary.tsx index 28aac68..8b47833 100644 --- a/src/components/organisms/layout/summary.tsx +++ b/src/components/organisms/layout/summary.tsx @@ -5,7 +5,7 @@ import Link from '@components/atoms/links/link'; import ResponsiveImage, { type ResponsiveImageProps, } from '@components/molecules/images/responsive-image'; -import Meta, { type MetaItem } from '@components/molecules/layout/meta'; +import Meta, { MetaData } from '@components/molecules/layout/meta'; import { FC, ReactNode } from 'react'; import { useIntl } from 'react-intl'; import styles from './summary.module.scss'; @@ -15,24 +15,15 @@ export type Cover = Pick< 'alt' | 'src' | 'width' | 'height' >; -export type RequiredMetaKey = 'publication'; - -export type RequiredMeta = { - [key in RequiredMetaKey]: MetaItem; -}; - -export type OptionalMetaKey = +export type SummaryMeta = Pick< + MetaData, | 'author' - | 'categories' - | 'comments' + | 'commentsCount' + | 'publication' | 'readingTime' - | 'update'; - -export type OptionalMeta = { - [key in OptionalMetaKey]?: MetaItem; -}; - -export type Meta = RequiredMeta & OptionalMeta; + | 'thematics' + | 'update' +>; export type SummaryProps = { /** @@ -46,7 +37,7 @@ export type SummaryProps = { /** * The post meta. */ - meta: Meta; + meta: SummaryMeta; /** * The post title. */ @@ -100,7 +91,11 @@ const Summary: FC<SummaryProps> = ({ </Link> </header> <div className={styles.body}> - {excerpt} + {typeof excerpt === 'string' ? ( + <div dangerouslySetInnerHTML={{ __html: excerpt }} /> + ) : ( + excerpt + )} <ButtonLink target={url} className={styles['read-more']}> <> {readMore} |
