Update home.html
This commit is contained in:
1 parent
12006238cc
commit
fff324192e
1 file changed
+13
-7
@@ -5,28 +5,34 @@
|
|||||||
<h2 class="section-header">随笔<i class="ri-quill-pen-line"></i></h2>
|
<h2 class="section-header">随笔<i class="ri-quill-pen-line"></i></h2>
|
||||||
<div class="posts">
|
<div class="posts">
|
||||||
<!-- 使用 sort 对文章按 Weight 排序 -->
|
<!-- 使用 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 }}
|
{{ $paginator := .Paginate $posts }}
|
||||||
|
|
||||||
{{ range $paginator.Pages }}
|
{{ range $paginator.Pages }}
|
||||||
<div class="post">
|
<div class="post">
|
||||||
<div class="time">{{ .Date.Format "January 2, 2006" }}</div>
|
<div class="time">{{ .Date.Format "January 2, 2006" }}</div>
|
||||||
<a href="{{ .Permalink }}">{{ .Title }}</a>
|
<a href="{{ .Permalink }}">{{ .Title }}</a>
|
||||||
|
|
||||||
<!-- 计算每篇文章的发布时间与当前时间的差值 -->
|
<!-- 计算每篇文章的发布时间与当前时间的差值 -->
|
||||||
{{ $publishDate := .Date }}
|
{{ $publishDate := .Date }}
|
||||||
{{ $currentTime := now }}
|
{{ $currentTime := now }}
|
||||||
{{ $timeDiff := div (sub $currentTime.Unix $publishDate.Unix) 3600 }}
|
{{ $timeDiff := div (sub $currentTime.Unix $publishDate.Unix) 3600 }}
|
||||||
|
|
||||||
<!-- 判断发布时间是否小于 24 小时 -->
|
<!-- 判断发布时间是否小于 24 小时,并且没有 weight 属性 -->
|
||||||
{{ if lt $timeDiff 24 }}
|
{{ if and (lt $timeDiff 24) (not .Params.weight) }}
|
||||||
<span class="new-post-message"></span>
|
<span class="new-post-message"></span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
<!-- 判断发布时间和 weight 属性 -->
|
||||||
|
{{ if .Params.weight }}
|
||||||
|
<!-- 如果有 weight 属性,添加 pushpin 图标 -->
|
||||||
|
<i class="ri-pushpin-line"></i>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
<ul class="pagination">
|
<ul class="pagination">
|
||||||
<li class="page-item page-next">
|
<li class="page-item page-next">
|
||||||
{{ if $paginator.HasNext }}
|
{{ if $paginator.HasNext }}
|
||||||
|
|||||||
Reference in new issue
Block a user