Files
blog/themes/Ying/layouts/_default/home.html
T

49 lines
2.3 KiB
HTML
Raw Normal View History

2024-07-11 08:59:32 +08:00
{{ define "main" }}
2026-01-20 20:09:46 +08:00
<div id="pjax-container">
2025-04-13 19:08:41 +08:00
<article>
<div class="recent-posts section">
2026-01-20 20:09:46 +08:00
<h2 class="section-header" uk-scrollspy="cls: uk-animation-slide-left-small; delay: 200">随笔<i class="ri-quill-pen-line"></i></h2>
<div class="posts" uk-scrollspy="target: > .post; cls: uk-animation-slide-bottom-small; delay: 150">
2025-04-13 19:08:41 +08:00
<!-- 使用 sort 对文章按 Weight 排序 -->
{{ $posts := sort (where (where .Site.RegularPages "Type" "post") "Params.status" "ne" "hidden")
"Weight" }}
{{ $paginator := .Paginate $posts }}
{{ range $paginator.Pages }}
<div class="post">
<div class="time">{{ .Date.Format "January 2, 2006" }}</div>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<!-- 计算每篇文章的发布时间与当前时间的差值 -->
{{ $publishDate := .Date }}
{{ $currentTime := now }}
{{ $timeDiff := div (sub $currentTime.Unix $publishDate.Unix) 3600 }}
<!-- 判断发布时间是否小于 24 小时,并且没有 weight 属性 -->
{{ if and (lt $timeDiff 24) (not .Params.weight) }}
<span class="new-post-message"></span>
{{ end }}
<!-- 判断发布时间和 weight 属性 -->
{{ if .Params.weight }}
<!-- 如果有 weight 属性,添加 pushpin 图标 -->
<img src="/image/zd_top.png" alt="" srcset="" style="width: 19px;position: relative;bottom: 2px;right: 3px;box-shadow: 0 0px 0px rgba(0, 0, 0, 0.2);cursor: pointer;transform: 1s;">
{{ end }}
</div>
{{ end }}
</div>
2024-07-11 08:59:32 +08:00
</div>
2025-04-13 19:08:41 +08:00
</article>
<ul class="pagination">
<li class="page-item page-next">
{{ if $paginator.HasNext }}
<a class="next" title="下一页" href="{{ $paginator.Next.URL }}">下一页</a>
{{ end }}
</li>
<li class="page-item page-previous">
{{ if $paginator.HasPrev }}
<a class="prev" title="上一页" href="{{ $paginator.Prev.URL }}">上一页</a>
{{ end }}
</li>
</ul>
2024-07-11 08:59:32 +08:00
</div>
2025-04-13 19:08:41 +08:00
{{ end }}