Skip to content

Commit 2835f73

Browse files
committed
fix: workaround for medium avatars cors problem
1 parent 1d10ff9 commit 2835f73

11 files changed

+49
-28
lines changed
Loading
Loading
Loading
Loading
Loading

components/PublicationCard/PublicationCard.module.scss

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@
2323
}
2424

2525
h2 {
26-
font-family: "Conduit ITC W04 Regular", 'system-ui';
26+
font-family: "Conduit ITC W04 Regular", "system-ui";
2727
font-size: 180%;
2828
}
2929
}
3030

3131
.publication-card--avatar {
3232
background-color: $red;
33-
background-size: 50px;
3433
border-radius: 50%;
3534
color: black;
3635
height: 50px;
@@ -39,6 +38,16 @@
3938
text-align: center;
4039
font-size: 40px;
4140
font-family: "Righteous", sans-serif;
41+
42+
.publication-card--avatar-img {
43+
border-radius: 50%;
44+
height: 50px;
45+
width: 50px;
46+
position: absolute;
47+
top: 0;
48+
background-size: 50px;
49+
overflow: hidden;
50+
}
4251
}
4352

4453
.publication-card--author {

components/PublicationCard/PublicationCard.tsx

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,19 @@ import { formatDate } from "../../lib/formatDate";
33
import { IPublication } from "../../lib/publications/publications.types";
44
// import SanitizedHTML from 'react-sanitized-html';
55
import styles from "./PublicationCard.module.scss";
6+
import { PublicationCardAvatar } from "./PublicationCardAvatar";
67

78
interface IPublicationCardProps {
89
publication: IPublication;
910
}
1011

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-
2312
const PublicationCard: FC<IPublicationCardProps> = ({ publication }) => {
2413
const { title, author, uniqueSlug, latestPublishedAt } = publication;
25-
const avatar = avatars[author.toLowerCase()];
14+
2615
return (
2716
<a href={uniqueSlug} className={styles["publication-card"]}>
2817
<section>
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()}
40-
</div>
18+
<PublicationCardAvatar author={author} />
4119
<div>
4220
<p className={styles["publication-card--author"]}>{author}</p>
4321
<p className={styles["publication-card--date"]}>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { FC } from "react";
2+
import styles from "./PublicationCard.module.scss";
3+
import nathanImg from "./0_Bqr-dMZplB-namyY.jpg";
4+
import mdworldImg from "./0_gTl35Xy5zRcgu5wJ.png";
5+
import nickImg from "./2_k7vMxGfKwfqJ86TcprDA_Q.jpg";
6+
import hamzaImg from "./2_1JTGoMi8_nuGQVO1EoItXg.png";
7+
import bjornImg from "./0_o9UzuQyUwobacrCt.jpg";
8+
import Image, { StaticImageData } from "next/image";
9+
10+
const avatars: Record<string, StaticImageData> = {
11+
mdworld: mdworldImg,
12+
"nathan perdijk": nathanImg,
13+
"bjorn ‘bjeaurn’": bjornImg,
14+
"hamza haiken": hamzaImg,
15+
"nick ten veen": nickImg,
16+
};
17+
18+
export const PublicationCardAvatar: FC<{ author: string }> = ({ author }) => {
19+
const avatar = avatars[author.toLowerCase()];
20+
21+
return (
22+
<div className={styles["publication-card--avatar"]}>
23+
<div className="letter">{author.slice(0, 1).toUpperCase()}</div>
24+
25+
<div className={styles["publication-card--avatar-img"]}>
26+
{avatar && <Image src={avatar} alt="avatar" width={50} height={50} />}
27+
</div>
28+
</div>
29+
);
30+
};

components/TopBar/TopBar.module.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
a {
3131
border-radius: 4px;
3232
padding: 10px;
33+
color: var(--cs-brutalist-creme);
3334

3435
&:hover {
3536
background-color: #222;

components/TopBar/TopBar.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ const TopBar: FC = () => {
1818
</li>
1919
<li>Codelancer</li> */}
2020
<li>
21-
<a href="https://www.ordina.nl/vakgebieden/scala/">Contact</a>
21+
<a href="https://www.linkedin.com/company/codestar-powered-by-sopra-steria/">
22+
Contact
23+
</a>
2224
</li>
2325
</ul>
2426
</div>

0 commit comments

Comments
 (0)