11---
22import type { CollectionEntry } from " astro:content" ;
3- import { getEntryUrl } from " ../blog " ;
4- import BaseHead from " ./BaseHead.astro " ;
3+ import { getEntry } from " astro:content " ;
4+ import { getEntryDescription , getEntryUrl } from " ../blog " ;
55import FormattedDate from " ./FormattedDate.astro" ;
66import Link from " ./Link.astro" ;
77import type { Page } from " astro" ;
@@ -13,6 +13,12 @@ export interface Props {
1313
1414const { page, isMain } = Astro .props as Props ;
1515const posts = page .data ;
16+ const postsWithAuthors = await Promise .all (
17+ posts .map (async (post ) => ({
18+ post ,
19+ author: await getEntry (" authors" , post .data .author .id ),
20+ }))
21+ );
1622---
1723
1824<section >
@@ -28,18 +34,42 @@ const posts = page.data;
2834 }
2935 <ul class =" col gap-md align-stretch pv-md ph-xs" >
3036 {
31- posts .map ((post ) => (
37+ postsWithAuthors .map (({ post , author } ) => (
3238 <li >
3339 <Link
3440 variant = " secondary"
3541 href = { ` /${getEntryUrl (post )} ` }
3642 look = " card"
37- class = " row align-center wrap w-full p-sm no-decoration"
43+ class = " blog-list-item w-full p-sm no-decoration"
3844 >
39- <div class = " w-md h-full bold" >
40- <FormattedDate date = { post .data .date } />
45+ <div class = " blog-list-meta" >
46+ <div class = " blog-list-date bold" >
47+ <FormattedDate date = { post .data .date } />
48+ </div >
49+ {
50+ author && (
51+ <p class = " blog-list-author m-none" >
52+ <span class = " blog-list-avatar" >
53+ <img
54+ src = { author .data .avatar }
55+ width = { 32 }
56+ height = { 32 }
57+ alt = " "
58+ loading = " lazy"
59+ decoding = " async"
60+ />
61+ </span >
62+ <span >{ author .data .name } </span >
63+ </p >
64+ )
65+ }
66+ </div >
67+ <div class = " blog-list-content" >
68+ <p class = " highlight m-none" >{ post .data .title } </p >
69+ <p class = " blog-list-description m-none" >
70+ { getEntryDescription (post )}
71+ </p >
4172 </div >
42- <p class = " highlight" >{ post .data .title } </p >
4373 </Link >
4474 </li >
4575 ))
@@ -67,3 +97,76 @@ const posts = page.data;
6797 </div >
6898 </div >
6999</section >
100+
101+ <style >
102+ .blog-list-item {
103+ display: grid;
104+ grid-template-columns: 10rem minmax(0, 1fr);
105+ align-items: center;
106+ column-gap: 1.5rem;
107+ row-gap: 0.35rem;
108+ }
109+
110+ .blog-list-meta {
111+ display: flex;
112+ flex-direction: column;
113+ gap: 0.4rem;
114+ min-width: 0;
115+ }
116+
117+ .blog-list-date {
118+ white-space: nowrap;
119+ }
120+
121+ .blog-list-content {
122+ min-width: 0;
123+ display: flex;
124+ flex-direction: column;
125+ gap: 0.15rem;
126+ }
127+
128+ .blog-list-author {
129+ display: inline-flex;
130+ align-items: center;
131+ gap: 0.4rem;
132+ color: var(--ls-background-text);
133+ font-size: 0.9rem;
134+ opacity: 0.72;
135+ }
136+
137+ .blog-list-avatar {
138+ display: inline-flex;
139+ align-items: center;
140+ justify-content: center;
141+ width: 1.35rem;
142+ height: 1.35rem;
143+ aspect-ratio: 1;
144+ border-radius: 50%;
145+ overflow: hidden;
146+ flex: 0 0 auto;
147+ }
148+
149+ .blog-list-avatar img {
150+ display: block;
151+ width: 100% !important;
152+ height: 100% !important;
153+ max-width: none;
154+ border-radius: inherit;
155+ object-fit: cover;
156+ }
157+
158+ .blog-list-description {
159+ color: var(--ls-background-text);
160+ opacity: 0.82;
161+ overflow: hidden;
162+ text-overflow: ellipsis;
163+ white-space: nowrap;
164+ }
165+
166+ @media (max-width: 640px) {
167+ .blog-list-item {
168+ grid-template-columns: 1fr;
169+ align-items: start;
170+ }
171+ }
172+ </style >
0 commit comments