SanYeCao-blog/src/components/Posts/PostItem.astro

174 lines
3.2 KiB
Text
Raw Normal View History

2026-03-24 17:33:01 +00:00
---
2026-03-25 09:01:09 +00:00
import "@/styles/global.css";
import Remark42Count from "@/components/remark42-counter.svelte";
2026-03-24 23:40:19 +00:00
const data = Astro.props;
2026-03-24 17:33:01 +00:00
---
2026-03-24 23:40:19 +00:00
<li class="post-card">
2026-03-25 10:38:01 +00:00
<a href={data.url} class="post-link" data-astro-reload>
2026-03-24 23:40:19 +00:00
<div class="post-text">
<span class="post-title">{data.title}</span>
<span class="post-description">{data.description}</span>
2026-03-25 08:43:02 +00:00
<div class="post-meta-row">
<span class="post-date">{data.date}</span>
<span class="post-stats">
<span class="post-stat">
💬 <Remark42Count url={data.postPath} client:idle />
</span>
2026-03-25 08:43:02 +00:00
</span>
</div>
2026-03-24 23:40:19 +00:00
</div>
2026-03-30 17:12:36 +00:00
<img src={data.img} alt={data.title} class="post-image" loading="lazy" />
2026-03-24 23:40:19 +00:00
</a>
2026-03-24 17:33:01 +00:00
</li>
2026-03-24 23:40:19 +00:00
<div class="section-divider"></div>
2026-03-24 17:33:01 +00:00
<style>
2026-03-24 23:40:19 +00:00
.post-card {
list-style: none;
margin: 0 0 1rem 0;
padding-left: 0;
2026-04-11 23:26:38 +00:00
padding-bottom: 0.2rem;
padding-top: 0.2rem;
2026-03-24 23:40:19 +00:00
}
.post-link {
2026-03-24 17:33:01 +00:00
display: flex;
justify-content: space-between;
2026-03-24 23:40:19 +00:00
align-items: stretch;
gap: 1rem;
2026-03-24 17:33:01 +00:00
width: 100%;
text-decoration: none;
}
2026-03-24 23:40:19 +00:00
.post-text {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
justify-content: space-between;
line-height: 1.6;
min-height: calc(1.6em * 4);
}
.post-title {
2026-04-11 17:46:53 +00:00
font-family:
sans-serif,
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
Oxygen,
Ubuntu,
Cantarell,
"Open Sans",
"Helvetica Neue";
2026-03-24 23:40:19 +00:00
color: inherit;
font-weight: 700;
2026-03-25 09:01:09 +00:00
font-size: 1.34rem;
2026-03-24 23:40:19 +00:00
line-height: 1.6;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
2026-03-25 08:43:02 +00:00
.post-description {
color: black;
font-weight: 400;
font-style: italic;
}
.post-meta-row {
display: flex;
align-items: center;
gap: 0.9rem;
flex-wrap: wrap;
}
2026-03-24 23:40:19 +00:00
.post-date {
color: gray;
font-size: 0.95rem;
2026-03-24 17:33:01 +00:00
white-space: nowrap;
2026-03-24 23:40:19 +00:00
line-height: 1.6;
}
2026-03-25 08:43:02 +00:00
.post-stats {
display: inline-flex;
align-items: center;
gap: 0.7rem;
color: #6f8090;
font-size: 0.92rem;
line-height: 1.6;
white-space: nowrap;
}
.post-stat {
display: inline-flex;
align-items: center;
gap: 0.2rem;
}
2026-03-24 23:40:19 +00:00
.post-image {
width: calc((1.6em * 4) * 16 / 9);
height: calc(1.6em * 4);
aspect-ratio: 16 / 9;
object-fit: cover;
object-position: center;
border-radius: 0.5rem;
flex-shrink: 0;
display: block;
}
:global(.dark) .post-description {
color: #e6e6e6;
}
2026-03-25 08:43:02 +00:00
:global(.dark) .post-stats {
color: #aab7c4;
}
2026-03-24 23:40:19 +00:00
@media (max-width: 640px) {
.post-link {
display: grid;
grid-template-columns: 1fr 120px;
grid-template-areas:
"title title"
"desc image"
"meta image";
column-gap: 0.75rem;
row-gap: 0.2rem;
align-items: start;
}
.post-text {
display: contents;
min-height: auto;
}
.post-title {
grid-area: title;
-webkit-line-clamp: 2;
}
.post-description {
grid-area: desc;
}
.post-meta-row {
grid-area: meta;
gap: 0.7rem;
2026-03-24 23:40:19 +00:00
}
.post-image {
grid-area: image;
2026-03-24 23:40:19 +00:00
width: 120px;
height: calc(120px * 9 / 16);
2026-03-24 17:33:01 +00:00
}
2026-03-24 23:40:19 +00:00
}
</style>