fix: show featured_image on posts list page
Use featured_image.src/alt instead of featuredImage. Add post-image CSS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -52,6 +52,11 @@ const formatDate = (date: Date) =>
|
|||||||
{postsWithTags.map(({ post, tags, bylines }) => (
|
{postsWithTags.map(({ post, tags, bylines }) => (
|
||||||
<article class="post-item">
|
<article class="post-item">
|
||||||
<a href={`/posts/${post.id}`} class="post-link">
|
<a href={`/posts/${post.id}`} class="post-link">
|
||||||
|
{post.data.featured_image && (
|
||||||
|
<div class="post-image">
|
||||||
|
<img src={post.data.featured_image.src} alt={post.data.featured_image.alt} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div class="post-meta">
|
<div class="post-meta">
|
||||||
{bylines.length > 0 && (
|
{bylines.length > 0 && (
|
||||||
<>
|
<>
|
||||||
@@ -146,6 +151,19 @@ const formatDate = (date: Date) =>
|
|||||||
border-bottom: 1px solid var(--color-border-subtle);
|
border-bottom: 1px solid var(--color-border-subtle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.post-image {
|
||||||
|
margin-bottom: var(--spacing-4);
|
||||||
|
border-radius: var(--radius-lg);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-image img {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
aspect-ratio: 16 / 10;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
.post-item:first-child {
|
.post-item:first-child {
|
||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user