aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/MetaItems/Thematics/Thematics.tsx
blob: a127715c088bac85d97e4012e0e35f1963559421 (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
37
38
39
40
41
42
import { MetaKind } from '@ts/types/app';
import { ThematicPreview } from '@ts/types/taxonomies';
import Link from 'next/link';
import { useIntl } from 'react-intl';
import { MetaItem } from '..';

const Thematics = ({
  list,
  kind,
}: {
  list: ThematicPreview[];
  kind: MetaKind;
}) => {
  const intl = useIntl();

  const getThematics = () => {
    return list.map((thematic) => {
      return (
        <Link key={thematic.databaseId} href={`/thematique/${thematic.slug}`}>
          <a>{thematic.title}</a>
        </Link>
      );
    });
  };

  return (
    <MetaItem
      title={intl.formatMessage(
        {
          defaultMessage:
            '{thematicsCount, plural, =0 {Thematics:} one {Thematic:} other {Thematics:}}',
          description: 'Thematics: thematics list meta label',
        },
        { thematicsCount: list.length }
      )}
      values={getThematics()}
      kind={kind}
    />
  );
};

export default Thematics;