aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/PostFooter/PostFooter.tsx
blob: 06e86bcde33d0d3c28266576c648008bb2d4017a (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
43
44
45
46
import { ButtonLink } from '@components/Buttons';
import { t } from '@lingui/macro';
import { SubjectPreview } from '@ts/types/taxonomies';
import Image from 'next/image';
import Link from 'next/link';
import styles from './PostFooter.module.scss';

const PostFooter = ({ subjects }: { subjects: SubjectPreview[] }) => {
  const getSubjects = () => {
    return subjects.map((subject) => {
      return (
        <li className={styles.item} key={subject.id}>
          <ButtonLink target={`/sujet/${subject.slug}`}>
            {subject.featuredImage && (
              <Image
                src={subject.featuredImage.sourceUrl}
                alt={subject.featuredImage.altText}
                layout="intrinsic"
                width="20"
                height="20"
              />
            )}
            {subject.title}
          </ButtonLink>
        </li>
      );
    });
  };

  return (
    <footer>
      {subjects.length > 0 && (
        <>
          <dl className={styles.meta}>
            <dt>{t`Read more articles about:`}</dt>
            <dd>
              <ul className={styles.list}>{getSubjects()}</ul>
            </dd>
          </dl>
        </>
      )}
    </footer>
  );
};

export default PostFooter;