|
1 | 1 | import { FC } from "react"; |
2 | 2 | import { formatDate } from "../../lib/formatDate"; |
3 | 3 | import { IPublication } from "../../lib/publications/publications.types"; |
4 | | -// import { IPublication } from "../../lib/publications/getPublications"; |
5 | 4 | // import SanitizedHTML from 'react-sanitized-html'; |
6 | 5 | import styles from "./PublicationCard.module.scss"; |
7 | 6 |
|
8 | 7 | interface IPublicationCardProps { |
9 | 8 | publication: IPublication; |
10 | 9 | } |
11 | 10 |
|
| 11 | +const avatars: Record<string, string> = { |
| 12 | + mdworld: "https://miro.medium.com/fit/c/176/176/0*gTl35Xy5zRcgu5wJ.png", |
| 13 | + "nathan perdijk": |
| 14 | + "https://miro.medium.com/fit/c/88/88/0*Bqr-dMZplB-namyY.jpg", |
| 15 | + "bjorn ‘bjeaurn’": |
| 16 | + "https://miro.medium.com/fit/c/176/176/0*o9UzuQyUwobacrCt.jpeg", |
| 17 | + "hamza haiken": |
| 18 | + "https://miro.medium.com/fit/c/176/176/2*1JTGoMi8_nuGQVO1EoItXg.png", |
| 19 | + "nick ten veen": |
| 20 | + "https://miro.medium.com/fit/c/88/88/2*k7vMxGfKwfqJ86TcprDA_Q.jpeg", |
| 21 | +}; |
| 22 | + |
12 | 23 | const PublicationCard: FC<IPublicationCardProps> = ({ publication }) => { |
13 | | - const { title, author, uniqueSlug, paragraphs, latestPublishedAt } = |
14 | | - publication; |
| 24 | + const { title, author, uniqueSlug, latestPublishedAt } = publication; |
| 25 | + const avatar = avatars[author.toLowerCase()]; |
15 | 26 | return ( |
16 | 27 | <a href={uniqueSlug} className={styles["publication-card"]}> |
17 | 28 | <section> |
18 | | - {/* TODO map avatars */} |
19 | | - <div className={styles["publication-card--avatar"]}> |
20 | | - {author.slice(0, 1).toUpperCase()} |
| 29 | + <div |
| 30 | + className={styles["publication-card--avatar"]} |
| 31 | + style={ |
| 32 | + avatar |
| 33 | + ? { |
| 34 | + backgroundImage: `url(${avatar})`, |
| 35 | + } |
| 36 | + : {} |
| 37 | + } |
| 38 | + > |
| 39 | + {avatar ? "" : author.slice(0, 1).toUpperCase()} |
21 | 40 | </div> |
22 | 41 | <div> |
23 | 42 | <p className={styles["publication-card--author"]}>{author}</p> |
|
0 commit comments