Update home.html

This commit is contained in:
小赵同学 committed 2024-09-19 23:57:44 +08:00
1 parent 12006238cc
commit fff324192e
1 file changed
+13 -7
+13 -7
View File
@@ -5,28 +5,34 @@
<h2 class="section-header">随笔<i class="ri-quill-pen-line"></i></h2>
<div class="posts">
<!-- 使用 sort 对文章按 Weight 排序 -->
{{ $posts := sort (where (where .Site.RegularPages "Type" "post") "Params.status" "ne" "hidden") "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 小时 -->
{{ if lt $timeDiff 24 }}
<!-- 判断发布时间是否小于 24 小时,并且没有 weight 属性 -->
{{ if and (lt $timeDiff 24) (not .Params.weight) }}
<span class="new-post-message"></span>
{{ end }}
<!-- 判断发布时间和 weight 属性 -->
{{ if .Params.weight }}
<!-- 如果有 weight 属性,添加 pushpin 图标 -->
<i class="ri-pushpin-line"></i>
{{ end }}
</div>
{{ end }}
</div>
</div>
</article>
</article>
<ul class="pagination">
<li class="page-item page-next">
{{ if $paginator.HasNext }}