Make blog list cards fully clickable

This commit is contained in:
2026-11-15 09:18:36 +08:00
parent 8b13c76513
commit 88c8c36d02
4 changed files with 33 additions and 28 deletions
+3
View File
@@ -7,3 +7,6 @@ public/
# OS files
.DS_Store
Thumbs.db
# Local build check output
tmpcheck/
+17 -7
View File
@@ -186,30 +186,40 @@ figcaption.post-caption {
}
.footer-roadmap { padding: 1rem 0; }
/* ===== Homepage post list: entire card is clickable ===== */
#post-list .home-post-item {
/* ===== Post lists (home + /blog): whole card is one clickable link ===== */
#post-list .post-card {
display: block;
color: inherit;
text-decoration: none;
border-radius: 0.5rem;
padding: 0.75rem 1rem;
margin: 0 -1rem 0.5rem;
margin: 0 -1rem;
transition: background-color 0.15s ease;
}
#post-list .home-post-item h3 {
#post-list .post-card h3 {
margin-top: 0;
}
#post-list .home-post-item:hover {
#post-list .post-card:hover {
background-color: rgba(0, 0, 0, 0.04);
}
html.dark #post-list .home-post-item:hover {
html.dark #post-list .post-card:hover {
background-color: rgba(255, 255, 255, 0.06);
}
#post-list .home-post-item:focus-visible {
#post-list .post-card:focus-visible {
outline: 2px solid var(--hx-color-primary-500, currentColor);
outline-offset: 2px;
}
/* Home: spacing between cards */
#post-list .home-post-item {
margin-bottom: 0.5rem;
}
/* /blog list: keep the original item rhythm (旧 hx:mb-10 + h3 mt-8 的视觉间距) */
#post-list .blog-post-item {
margin-bottom: 1rem;
}
+12 -20
View File
@@ -21,34 +21,26 @@
<div id="post-list">
{{- range $i, $p := $pages }}
{{- /* 整块卡片即一个链接:框内任意位置点击都进入文章;
标签放在卡片外面,保证标签本身仍是可点链接 */}}
<div
class="hx:mb-10 blog-post-item{{ if ge $i $batch }} hx:hidden{{ end }}"
class="blog-post-item{{ if ge $i $batch }} hx:hidden{{ end }}"
data-index="{{ $i }}"
>
<h3>
<a
style="color: inherit; text-decoration: none"
class="hx:block hx:font-semibold hx:mt-8 hx:text-2xl"
href="{{ $p.RelPermalink }}"
>{{ $p.Title }}</a
>
</h3>
<p class="hx:opacity-50 hx:text-sm hx:mt-1 hx:leading-7">
{{ partial "utils/format-date" $p.Date }}
</p>
<a href="{{ $p.RelPermalink }}" class="post-card">
<h3 class="hx:text-2xl">{{ $p.Title }}</h3>
<p class="hx:opacity-50 hx:text-sm hx:mt-1 hx:leading-7">
{{ partial "utils/format-date" $p.Date }}
</p>
<p class="hx:opacity-80 hx:mt-2 hx:leading-7">
{{- partial "utils/page-description" $p -}}
</p>
</a>
{{ if site.Params.blog.list.displayTags }}
<div class="hx:text-sm hx:leading-7">
{{ partial "tags.html" (dict "context" $p) }}
</div>
{{ end }}
<a
href="{{ $p.RelPermalink }}"
style="color: inherit; text-decoration: none"
>
<p class="hx:opacity-80 hx:mt-2 hx:leading-7">
{{- partial "utils/page-description" $p -}}
</p>
</a>
</div>
{{- end }}
</div>
+1 -1
View File
@@ -18,7 +18,7 @@
{{- /* 整块卡片即一个链接:框内任意位置点击都进入文章 */}}
<a
href="{{ $p.RelPermalink }}"
class="home-post-item{{ if ge $i $batch }} hx:hidden{{ end }}"
class="home-post-item post-card{{ if ge $i $batch }} hx:hidden{{ end }}"
data-index="{{ $i }}"
>
<h3 class="hx:text-xl">{{ $p.Title }}</h3>