aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/PostFooter/PostFooter.tsx
blob: fe933d723ffdab1860ac5050088cc7399f35d708 (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
47
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}>
          <Link href={`/sujet/${subject.slug}`}>
            <a className={styles.link}>
              {subject.featuredImage && (
                <Image
                  src={subject.featuredImage.sourceUrl}
                  alt={subject.featuredImage.altText}
                  layout="intrinsic"
                  width="20"
                  height="20"
                />
              )}
              {subject.title}
            </a>
          </Link>
        </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;