From b9c1953c79688fc3f536b7927692309c9780b5da Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Thu, 6 Jan 2022 17:55:24 +0100 Subject: refactor: reuse PostMeta components on single articles/pages --- src/components/PostHeader/PostHeader.tsx | 82 ++++++++++---------------------- 1 file changed, 24 insertions(+), 58 deletions(-) (limited to 'src/components/PostHeader/PostHeader.tsx') diff --git a/src/components/PostHeader/PostHeader.tsx b/src/components/PostHeader/PostHeader.tsx index 3ee6705..e445b58 100644 --- a/src/components/PostHeader/PostHeader.tsx +++ b/src/components/PostHeader/PostHeader.tsx @@ -1,71 +1,37 @@ -import { t } from '@lingui/macro'; -import { Dates } from '@ts/types/app'; -import { ArticleAuthor } from '@ts/types/articles'; -import { ThematicPreview } from '@ts/types/taxonomies'; -import Link from 'next/link'; -import { useRouter } from 'next/router'; +import PostMeta from '@components/PostMeta/PostMeta'; +import { ArticleMeta } from '@ts/types/articles'; +import { Cover } from '@ts/types/cover'; +import Image from 'next/image'; import styles from './PostHeader.module.scss'; const PostHeader = ({ - author, - dates, + cover, intro, title, - thematics, + meta, }: { - author: ArticleAuthor; - dates: Dates; + cover?: Cover; intro: string; + meta?: ArticleMeta; title: string; - thematics: ThematicPreview[]; }) => { - const { locale } = useRouter(); - - const getAuthor = () => { - return author.firstName - ? `${author.firstName} ${author.lastName}` - : author.name; - }; - - const getLocaleDate = (date: string) => { - const dateOptions: Intl.DateTimeFormatOptions = { - day: 'numeric', - month: 'long', - year: 'numeric', - }; - return new Date(date).toLocaleDateString(locale, dateOptions); - }; - - const getThematics = () => { - return thematics.map((thematic) => { - return ( -
- - {thematic.title} - -
- ); - }); - }; - return ( -
-

{title}

- -
+
+
+

+ {cover && ( + + {cover.altText} + + )} + {title} +

+ {meta && } +
+
); }; -- cgit v1.2.3