|
2 | 2 | import Media from '$lib/UI/Media.svelte'; |
3 | 3 | import { formatDate } from '$lib/utils/date'; |
4 | 4 |
|
| 5 | + import type { AuthorInfo } from '$lib/utils/blog-authors'; |
| 6 | +
|
5 | 7 | interface ArticleProps { |
6 | 8 | title: string; |
7 | 9 | cover: string; |
8 | 10 | href: string; |
9 | 11 | date: Date; |
10 | 12 | timeToRead: number; |
11 | | - author: string; |
12 | | - avatar: string; |
| 13 | + authors: AuthorInfo[]; |
| 14 | + avatars: string[]; |
13 | 15 | } |
14 | 16 |
|
15 | | - const { title, cover, href, date, timeToRead, author, avatar }: ArticleProps = $props(); |
| 17 | + const { title, cover, href, date, timeToRead, authors, avatars }: ArticleProps = $props(); |
| 18 | +
|
| 19 | + const authorAvatarPairs = $derived( |
| 20 | + avatars.map((avatar, i) => ({ avatar, author: authors[i] })).filter(({ avatar }) => avatar) |
| 21 | + ); |
16 | 22 | </script> |
17 | 23 |
|
18 | 24 | <li> |
19 | | - <a class="bg-transparent" {href}> |
20 | | - <div class="overflow-hidden rounded-lg"> |
21 | | - <Media |
22 | | - src={cover} |
23 | | - class="aspect-video transition-transform duration-250 hover:scale-105" |
24 | | - alt={title} |
25 | | - autoplay |
26 | | - controls={false} |
27 | | - /> |
| 25 | + <a class="block overflow-hidden rounded-lg bg-transparent" {href}> |
| 26 | + <Media |
| 27 | + src={cover} |
| 28 | + class="aspect-video transition-transform duration-250 hover:scale-105" |
| 29 | + alt={title} |
| 30 | + autoplay |
| 31 | + controls={false} |
| 32 | + /> |
| 33 | + </a> |
| 34 | + <div class="flex flex-col gap-3 pt-6 pb-3"> |
| 35 | + <div class="text-caption text-secondary"> |
| 36 | + {formatDate(date)} - {timeToRead} min |
28 | 37 | </div> |
29 | | - <div class="flex flex-col gap-3 pt-6 pb-3"> |
30 | | - <h4 class="text-label font-aeonik-pro text-primary line-clamp-2"> |
| 38 | + <a {href} class="bg-transparent"> |
| 39 | + <h4 class="text-label font-aeonik-pro text-primary line-clamp-2 hover:underline"> |
31 | 40 | {title} |
32 | 41 | </h4> |
33 | | - <div class="flex w-full"> |
34 | | - <div |
35 | | - class="text-paragraph-md flex w-full flex-col items-center xl:flex-row xl:gap-2" |
36 | | - > |
37 | | - <div class="flex items-center justify-center gap-2"> |
38 | | - <img class="size-5 rounded-full" loading="lazy" src={avatar} alt={author} /> |
39 | | - <h4 class="text-primary">{author}</h4> |
40 | | - </div> |
41 | | - <div class="text-secondary ml-7 flex xl:ml-0"> |
42 | | - <span> |
43 | | - {formatDate(date)} |
44 | | - </span> |
45 | | - <span class="before:mx-1 xl:before:content-['-']">{timeToRead} min</span> |
46 | | - </div> |
47 | | - </div> |
| 42 | + </a> |
| 43 | + <div class="text-paragraph-md flex flex-wrap items-center gap-2"> |
| 44 | + <div class="flex items-center"> |
| 45 | + {#each authorAvatarPairs as { avatar, author }, i} |
| 46 | + <img |
| 47 | + class="size-5 rounded-full ring-2 ring-[#19191c]" |
| 48 | + style="margin-inline-start: {i > 0 |
| 49 | + ? '-4px' |
| 50 | + : '0'}; z-index: {authorAvatarPairs.length - i}" |
| 51 | + loading="lazy" |
| 52 | + src={avatar} |
| 53 | + alt={author?.name ?? ''} |
| 54 | + /> |
| 55 | + {/each} |
48 | 56 | </div> |
| 57 | + <span class="text-primary"> |
| 58 | + {#each authors as author, i} |
| 59 | + <a href={author.href} class="hover:underline">{author.name}</a |
| 60 | + >{#if i < authors.length - 1},{' '}{/if} |
| 61 | + {/each} |
| 62 | + </span> |
49 | 63 | </div> |
50 | | - </a> |
| 64 | + </div> |
51 | 65 | </li> |
0 commit comments