diff options
Diffstat (limited to 'src/components/PostMeta/PostMeta.tsx')
| -rw-r--r-- | src/components/PostMeta/PostMeta.tsx | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/components/PostMeta/PostMeta.tsx b/src/components/PostMeta/PostMeta.tsx index 6d40048..ece355a 100644 --- a/src/components/PostMeta/PostMeta.tsx +++ b/src/components/PostMeta/PostMeta.tsx @@ -13,14 +13,31 @@ const PostMeta = ({ meta: ArticleMeta; mode?: PostMetaMode; }) => { - const { author, commentCount, dates, thematics, website } = meta; - const { locale } = useRouter(); + const { author, commentCount, dates, subjects, thematics, website } = meta; + const { asPath, locale } = useRouter(); + const isThematic = () => asPath.includes('/thematique/'); + const dateOptions: Intl.DateTimeFormatOptions = { day: 'numeric', month: 'long', year: 'numeric', }; + const getSubjects = () => { + return ( + subjects && + subjects.map((subject) => { + return ( + <dd key={subject.id} className={styles.description}> + <Link href={`/sujet/${subject.slug}`}> + <a>{subject.title}</a> + </Link> + </dd> + ); + }) + ); + }; + const getThematics = () => { return ( thematics && @@ -76,7 +93,7 @@ const PostMeta = ({ </dd> </div> )} - {thematics && thematics.length > 0 && ( + {!isThematic() && thematics && thematics.length > 0 && ( <div className={styles.item}> <dt className={styles.term}> {thematics.length > 1 ? t`Thematics` : t`Thematic`} @@ -84,6 +101,14 @@ const PostMeta = ({ {getThematics()} </div> )} + {isThematic() && subjects && subjects.length > 0 && ( + <div className={styles.item}> + <dt className={styles.term}> + {subjects.length > 1 ? t`Subjects` : t`Subject`} + </dt> + {getSubjects()} + </div> + )} {website && ( <div className={styles.item}> <dt className={styles.term}>{t`Website`}</dt> |
