diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-03-01 22:05:08 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-03-01 22:05:08 +0100 |
| commit | 8bd9784acdee6871ad70e86d0d7120299bf76969 (patch) | |
| tree | 9b81e0cd3ff881b2cbeb81f9f96b52b510d67646 /src/components/MetaItems/Topics | |
| parent | 21c228600a7a69cfea3b7d8af6838bcfda1d7399 (diff) | |
refactor: split posts meta into smaller components
Diffstat (limited to 'src/components/MetaItems/Topics')
| -rw-r--r-- | src/components/MetaItems/Topics/Topics.tsx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/components/MetaItems/Topics/Topics.tsx b/src/components/MetaItems/Topics/Topics.tsx new file mode 100644 index 0000000..4f2dc1f --- /dev/null +++ b/src/components/MetaItems/Topics/Topics.tsx @@ -0,0 +1,36 @@ +import { MetaKind } from '@ts/types/app'; +import { TopicPreview } from '@ts/types/taxonomies'; +import Link from 'next/link'; +import { useIntl } from 'react-intl'; +import { MetaItem } from '..'; + +const Topics = ({ list, kind }: { list: TopicPreview[]; kind: MetaKind }) => { + const intl = useIntl(); + + const getTopics = () => { + return list.map((topic) => { + return ( + <Link key={topic.databaseId} href={`/sujet/${topic.slug}`}> + <a>{topic.title}</a> + </Link> + ); + }); + }; + + return ( + <MetaItem + title={intl.formatMessage( + { + defaultMessage: + '{topicsCount, plural, =0 {Topics:} one {Topic:} other {Topics:}}', + description: 'Topics: topics list meta label', + }, + { topicsCount: list.length } + )} + values={getTopics()} + kind={kind} + /> + ); +}; + +export default Topics; |
