From 0d59a6d2995b4119865271ed1908ede0bb96497c Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 9 May 2022 18:19:38 +0200 Subject: 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. --- src/components/organisms/layout/summary.tsx | 33 ++++++++++++----------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'src/components/organisms/layout/summary.tsx') 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 = ({
- {excerpt} + {typeof excerpt === 'string' ? ( +
+ ) : ( + excerpt + )} <> {readMore} -- cgit v1.2.3