aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Widgets/RelatedThematics/RelatedThematics.tsx
blob: afe34600a6ad229cde854c03538e0ddc15fd7dca (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
import { ExpandableWidget, List } from '@components/WidgetParts';
import { t } from '@lingui/macro';
import { ThematicPreview } from '@ts/types/taxonomies';
import Link from 'next/link';

const RelatedThematics = ({ thematics }: { thematics: ThematicPreview[] }) => {
  const sortedThematics = [...thematics].sort((a, b) =>
    a.title.localeCompare(b.title)
  );

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

  return (
    <ExpandableWidget
      title={thematics.length > 1 ? t`Related thematics` : t`Related thematic`}
      withBorders={true}
    >
      <List items={thematicsList} />
    </ExpandableWidget>
  );
};

export default RelatedThematics;