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

43 lines
1.8 KiB
HTML
Raw Normal View History

2024-07-11 08:59:32 +08:00
{{ define "main" }}
2024-08-09 10:36:58 +08:00
<div id="pjax-container" uk-scrollspy="target: > div,a; cls: uk-animation-slide-bottom-small; delay: 0">
2024-07-11 08:59:32 +08:00
<article>
<div class="recent-posts section">
<h2 class="section-header">随笔<i class="ri-quill-pen-line"></i></h2>
<div class="posts">
2024-09-19 23:27:24 +08:00
<!-- 使用 ByWeight 来排序 -->
{{ $posts := where (where .Site.RegularPages "Type" "post") "Params.status" "ne" "hidden" | sort "Weight" "asc" }}
{{ $paginator := .Paginate $posts }}
2024-07-23 19:56:26 +08:00
{{ range $paginator.Pages }}
2024-07-11 08:59:32 +08:00
<div class="post">
<div class="time">{{ .Date.Format "January 2, 2006" }}</div>
<a href="{{ .Permalink }}">{{ .Title }}</a>
2024-09-19 23:27:24 +08:00
2024-08-12 11:51:03 +08:00
<!-- 计算每篇文章的发布时间与当前时间的差值 -->
{{ $publishDate := .Date }}
{{ $currentTime := now }}
{{ $timeDiff := div (sub $currentTime.Unix $publishDate.Unix) 3600 }}
2024-09-19 23:27:24 +08:00
2024-09-18 13:12:32 +08:00
<!-- 判断发布时间是否小于 24 小时 -->
2024-09-18 10:01:46 +08:00
{{ if lt $timeDiff 24 }}
2024-09-19 23:27:24 +08:00
<span class="new-post-message">New</span>
2024-08-12 11:51:03 +08:00
{{ end }}
2024-07-11 08:59:32 +08:00
</div>
{{ end }}
</div>
</div>
2024-09-19 23:27:24 +08:00
</article>
2024-07-11 08:59:32 +08:00
<ul class="pagination">
<li class="page-item page-next">
2024-07-23 19:56:26 +08:00
{{ if $paginator.HasNext }}
<a class="next" title="下一页" href="{{ $paginator.Next.URL }}">下一页</a>
2024-07-11 08:59:32 +08:00
{{ end }}
</li>
2024-07-26 11:24:34 +08:00
<li class="page-item page-previous">
{{ if $paginator.HasPrev }}
<a class="prev" title="上一页" href="{{ $paginator.Prev.URL }}">上一页</a>
{{ end }}
</li>
2024-07-11 08:59:32 +08:00
</ul>
</div>
2024-08-12 11:51:03 +08:00
{{ end }}