aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryingyu5658 <i@yingyu5658.me>2026-01-24 21:33:58 +0800
committeryingyu5658 <i@yingyu5658.me>2026-01-24 21:33:58 +0800
commitc08add089657efbed69165acdfa55a635df3c0aa (patch)
tree9d0ece56625cd45664471fb425f2b2b2ccb975bc
parent2ca49a309df9763cec3d45352b9b2013480d12c4 (diff)
downloadblog-c08add089657efbed69165acdfa55a635df3c0aa.tar.gz
blog-c08add089657efbed69165acdfa55a635df3c0aa.zip
style: tweak some CSS style about recent-posts
-rw-r--r--layouts/shortcodes/recent-posts.html112
1 files changed, 8 insertions, 104 deletions
diff --git a/layouts/shortcodes/recent-posts.html b/layouts/shortcodes/recent-posts.html
index 297a760..b1e891e 100644
--- a/layouts/shortcodes/recent-posts.html
+++ b/layouts/shortcodes/recent-posts.html
@@ -1,120 +1,24 @@
{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} {{
-$recent := first 8 $pages.ByDate.Reverse }}
+$recent := first 5 $pages.ByDate.Reverse }}
<style>
-
-hr.item-split {
- margin-bottom: 10px;
- margin-top: 10px;
- }
-
- p {
- line-height: 35px;
+.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;
- display: flex;
- align-items: flex-start;
- }
-
- .item-link {
- display: inline-block;
- text-decoration: none;
- flex: 1;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
-
- .post-date {
- font-size: 0.9em;
- color: #666;
- display: inline-block;
- min-width: 80px;
- flex-shrink: 0;
- }
-
- .category-link {
- font-size: 0.9em;
- }
-
- .recent-empty {
- text-align: center;
- font-style: italic;
- }
-
- .split {
- margin: 0;
- padding: 0;
- display: inline;
- }
-
- .recent-posts-item {
- margin-top: 0;
- margin-bottom: 0;
- }
-
- .recent-post-title {
- margin-top: 2px;
- margin-bottom: -10px;
- }
-
- @media (max-width: 720px) {
- .post-date {
- min-width: auto;
- font-size: 0.85em;
- }
-
- .recent-post-title {
- font-size: 1.05em;
- }
-
- .item-link {
- white-space: normal; /* 允许换行 */
- word-wrap: break-word; /* 强制长单词/链接换行 */
- overflow: visible; /* 取消隐藏 */
- text-overflow: clip; /* 取消省略号 */
- }
- }
</style>
<div class="recent-posts">
{{ 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>
- </span>
-
- {{ with .Params.categories }}
- {{ range . }}
- {{ $category := . }}
- {{ with $.Site.GetPage (printf "categories/%s" $category) }}
- <a href="{{ .Permalink }}" class="category-link">{{ .Title }}</a>
- {{ else }}
- <a href="{{ "categories/" | relLangURL}}{{ $category | urlize}}" class="category-link">{{ $category }}</a>
- {{ end }}
- {{ end }}
- {{ end }}
- </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>
+
+ {{ partial "post_meta.html" . }}
- <div class="summary">{{ .Summary }}</div>
- </div>
- <hr class="item-split">
- {{ end }} {{ else }}
+ {{ if not (eq (add $index 1) (len $recent)) }} {{ end }} {{ end }} {{ else }}
<div class="recent-empty">暂无文章</div>
{{ end }}
</div>