import { ButtonLink } from '@components/Buttons';
import { TopicPreview } from '@ts/types/taxonomies';
import Image from 'next/image';
import { useIntl } from 'react-intl';
import styles from './PostFooter.module.scss';

const PostFooter = ({ topics }: { topics: TopicPreview[] }) => {
  const intl = useIntl();

  const getTopics = () => {
    return topics.map((topic) => {
      return (
        <li className={styles.item} key={topic.id}>
          <ButtonLink target={`/sujet/${topic.slug}`}>
            {topic.featuredImage && (
              <Image
                src={topic.featuredImage.sourceUrl}
                alt={topic.featuredImage.altText}
                layout="intrinsic"
                width="20"
                height="20"
              />
            )}
            {topic.title}
          </ButtonLink>
        </li>
      );
    });
  };

  return (
    <footer>
      {topics.length > 0 && (
        <>
          <dl className={styles.meta}>
            <dt>
              {intl.formatMessage({
                defaultMessage: 'Read more articles about:',
                description: 'PostFooter: read more posts about given subjects',
              })}
            </dt>
            <dd>
              <ul className={styles.list}>{getTopics()}</ul>
            </dd>
          </dl>
        </>
      )}
    </footer>
  );
};

export default PostFooter;
ilippot.com/about/'>about</a><a href='/www.armandphilippot.com/'>summary</a><a href='/www.armandphilippot.com/refs/?id=26a1e3a7a08e4b0fdb4dfcc3ed6a6cc21bcef104'>refs</a><a href='/www.armandphilippot.com/log/src/components/molecules/forms/radio-group/index.ts'>log</a><a class='active' href='/www.armandphilippot.com/tree/src/components/molecules/forms/radio-group/index.ts?id=26a1e3a7a08e4b0fdb4dfcc3ed6a6cc21bcef104'>tree</a><a href='/www.armandphilippot.com/commit/src/components/molecules/forms/radio-group/index.ts?id=26a1e3a7a08e4b0fdb4dfcc3ed6a6cc21bcef104'>commit</a><a href='/www.armandphilippot.com/diff/src/components/molecules/forms/radio-group/index.ts?id=26a1e3a7a08e4b0fdb4dfcc3ed6a6cc21bcef104'>diff</a><a href='/www.armandphilippot.com/stats/src/components/molecules/forms/radio-group/index.ts'>stats</a></td><td class='form'><form class='right' method='get' action='/www.armandphilippot.com/log/src/components/molecules/forms/radio-group/index.ts'>
<input type='hidden' name='id' value='26a1e3a7a08e4b0fdb4dfcc3ed6a6cc21bcef104'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/www.armandphilippot.com/tree/?id=26a1e3a7a08e4b0fdb4dfcc3ed6a6cc21bcef104'>root</a>/<a href='/www.armandphilippot.com/tree/src?id=26a1e3a7a08e4b0fdb4dfcc3ed6a6cc21bcef104'>src</a>/<a href='/www.armandphilippot.com/tree/src/components?id=26a1e3a7a08e4b0fdb4dfcc3ed6a6cc21bcef104'>components</a>/<a href='/www.armandphilippot.com/tree/src/components/molecules?id=26a1e3a7a08e4b0fdb4dfcc3ed6a6cc21bcef104'>molecules</a>/<a href='/www.armandphilippot.com/tree/src/components/molecules/forms?id=26a1e3a7a08e4b0fdb4dfcc3ed6a6cc21bcef104'>forms</a>/<a href='/www.armandphilippot.com/tree/src/components/molecules/forms/radio-group?id=26a1e3a7a08e4b0fdb4dfcc3ed6a6cc21bcef104'>radio-group</a>/<a href='/www.armandphilippot.com/tree/src/components/molecules/forms/radio-group/index.ts?id=26a1e3a7a08e4b0fdb4dfcc3ed6a6cc21bcef104'>index.ts</a></div><div class='content'>blob: ed40543ed5943c89a4335138a91644d0d6cd0155 (<a href='/www.armandphilippot.com/plain/src/components/molecules/forms/radio-group/index.ts?id=26a1e3a7a08e4b0fdb4dfcc3ed6a6cc21bcef104'>plain</a>)
<table summary='blob content' class='blob'>
<tr><td class='linenumbers'><pre><a id='n1' href='#n1'>1</a>
</pre></td>
<td class='lines'><pre><code>