diff options
| author | yingyu5658 <i@yingyu5658.me> | 2026-01-13 22:33:08 +0800 |
|---|---|---|
| committer | yingyu5658 <i@yingyu5658.me> | 2026-01-13 22:33:08 +0800 |
| commit | 4c40685be4a919f4483febc6fc9249fa59651fae (patch) | |
| tree | 29f0c9b66f5d90a5d808b84355148f6577c6d54e /layouts/shortcodes/recent-posts.html | |
| parent | 16e2a3fd905c5ffb5e0a90c1a4805559d372b389 (diff) | |
| download | blog-4c40685be4a919f4483febc6fc9249fa59651fae.tar.gz blog-4c40685be4a919f4483febc6fc9249fa59651fae.zip | |
style: show the summary of every post on recent-posts
Diffstat (limited to 'layouts/shortcodes/recent-posts.html')
| -rw-r--r-- | layouts/shortcodes/recent-posts.html | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/layouts/shortcodes/recent-posts.html b/layouts/shortcodes/recent-posts.html index 7b3d855..297a760 100644 --- a/layouts/shortcodes/recent-posts.html +++ b/layouts/shortcodes/recent-posts.html @@ -1,7 +1,17 @@ -{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} -{{ $recent := first 8 $pages.ByDate.Reverse }} +{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} {{ +$recent := first 8 $pages.ByDate.Reverse }} <style> + +hr.item-split { + margin-bottom: 10px; + margin-top: 10px; + } + + p { + line-height: 35px; + } + .recent-list { margin: 0; } @@ -44,23 +54,22 @@ } .split { - margin: 0; - padding: 0; - display: inline; + margin: 0; + padding: 0; + display: inline; } .recent-posts-item { - margin-top: 0; - margin-bottom: 35px; + margin-top: 0; + margin-bottom: 0; } .recent-post-title { - margin-top: 2px; - margin-bottom: -10px; + margin-top: 2px; + margin-bottom: -10px; } @media (max-width: 720px) { - .post-date { min-width: auto; font-size: 0.85em; @@ -70,7 +79,7 @@ font-size: 1.05em; } - .item-link { + .item-link { white-space: normal; /* 允许换行 */ word-wrap: break-word; /* 强制长单词/链接换行 */ overflow: visible; /* 取消隐藏 */ @@ -80,16 +89,10 @@ </style> <div class="recent-posts"> - {{ if $recent }} - {{ range $index, $page := $recent }} - <div class="recent-posts-item"> - <h3 class="recent-post-title"> - <a href="{{ .RelPermalink }}" class="item-link">{{ .Title }}</a> - </h3> - + {{ if $recent }} {{ range $index, $page := $recent }} <div class="post-meta"> <span class="post-date"> - <time datetime='{{ .Date.Format "Jan 02, 2006" }}'>{{- .Date.Format (default "Jan 02, 2006" .Site.Params.dateFormat) -}}•</time> + <time datetime='{{ .Date.Format "Jan 02, 2006" }}'>{{- .Date.Format (default "Jan 02, 2006" .Site.Params.dateFormat) -}}·</time> </span> {{ with .Params.categories }} @@ -103,9 +106,15 @@ {{ end }} {{ end }} </div> - </div> - {{ end }} - {{ else }} - <div class="recent-empty">暂无文章</div> + <div class="recent-posts-item"> + <h3 class="recent-post-title"> + <a href="{{ .RelPermalink }}" class="item-link">{{ .Title }}</a> + </h3> + + <div class="summary">{{ .Summary }}</div> + </div> + <hr class="item-split"> + {{ end }} {{ else }} + <div class="recent-empty">暂无文章</div> {{ end }} </div> |
