aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/MetaItems/Topics/Topics.tsx
blob: 4f2dc1ff6e11b44ef37122f936f67951c5e5d821 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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;