From 5b1ddd7cc2ad7f334b1d29b7374c818614e654bd Mon Sep 17 00:00:00 2001 From: verdant Date: Sun, 22 Mar 2026 11:30:43 +0800 Subject: style: refactor index layout --- layouts/partials/post_meta.html | 20 ++--- layouts/partials/style.html | 15 ++-- layouts/shortcodes/recent-posts.html | 140 ++++++++++++++++++++++++++++++----- 3 files changed, 140 insertions(+), 35 deletions(-) diff --git a/layouts/partials/post_meta.html b/layouts/partials/post_meta.html index 741efd2..1c180c3 100644 --- a/layouts/partials/post_meta.html +++ b/layouts/partials/post_meta.html @@ -1,33 +1,24 @@ {{ if ne (.Params.showMeta | default true) false }}
- - + {{ if eq .Kind "page" }} + {{ end }}
{{ end }} + + diff --git a/layouts/partials/style.html b/layouts/partials/style.html index 33ba584..ec4dae2 100644 --- a/layouts/partials/style.html +++ b/layouts/partials/style.html @@ -19,8 +19,7 @@ --upvoted-color: #fa8072; --caption-text-color: #666; --toc-text-color: #e5e5e5; - --toc-hover-color -: e5e5e5; + --toc-hover-color: e5e5e5; --music-bg-hover-light: #e5e5e5; --music-bg-light: rgba(229, 229, 229, 0.5); --music-text-secondary: #666; @@ -73,6 +72,10 @@ h1, h2 { color: var(--body-text-color) } +.post-meta-item a { + font-size: .85rem; +} + body { @@ -280,9 +283,8 @@ ul.blog-posts li span.grouped { } .post-meta-item { - margin-right: 0.8em; + margin-right: 0.3rem; display: inline-block; - font-size: var(--font-size-secondary); } .post-meta-item svg { @@ -296,7 +298,6 @@ ul.blog-posts li span.grouped { } .post-tag a { - font-size: var(--font-size-secondary) !important; } img { @@ -647,6 +648,10 @@ ul li:has(input) { text-decoration: none; } +h3.recent-post-title a { +color: var(--body-text-color); +} + a:hover { text-decoration: underline; } diff --git a/layouts/shortcodes/recent-posts.html b/layouts/shortcodes/recent-posts.html index ea6ed2b..a666a4c 100644 --- a/layouts/shortcodes/recent-posts.html +++ b/layouts/shortcodes/recent-posts.html @@ -1,30 +1,136 @@ {{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} {{ -$recent := first 5 $pages.ByDate.Reverse }} +$recent := first 6 $pages.ByDate.Reverse }} + .item-link { + word-wrap: break-word; + white-space: normal; + } + .recent-list { + margin: 0; + } + .post-meta { + margin-bottom: 5px; + } + .recent-item { + position: relative; + margin-bottom: 8px; + flex-shrink: 0; + } + .split { + margin: 0; + padding: 0; + display: inline; + } + .recent-posts-item { + margin-top: 0; + margin-bottom: 35px; + } + .recent-post-title { + margin-top: 2px; + margin-bottom: -10px; - - - - + } + @media (max-width: 720px) { + .post-date { + min-width: auto; + font-size: 1.05em; + } + .item-link { + white-space: normal; /* 允许换行 */ + word-wrap: break-word; /* 强制长单词/链接换行 */ + overflow: visible; /* 取消隐藏 */ + text-overflow: clip; /* 取消省略号 */ + } + } + .category-link { + font-size: 0.9em; + } + .recent-empty { + text-align: center; + font-style: italic; + } +
- {{ if $recent }} {{ range $index, $page := $recent }} + + {{ if $recent }} + {{ range $index, $page := $recent }}
-

+

{{ .Title }} -

-
{{ .Summary }}
+ - {{ partial "post_meta.html" . }} +{{ if ne (.Params.showMeta | default true) false }} + +{{ end }} + + + + + + + + + + + + + + + + + + + + + + + + +
{{ end }} + {{ else }} +
暂无文章
+ +
+ +{{ end }} + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3