49 lines
2.9 KiB
HTML
49 lines
2.9 KiB
HTML
{{ define "main" }}
|
|
<div id="pjax-container" uk-scrollspy="target: > div,a; cls: uk-animation-slide-bottom-small; delay: 0">
|
|
<article>
|
|
<div class="recent-posts section">
|
|
<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" }}
|
|
{{ $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 图标 -->
|
|
<svg t="1726831630742" style="width: 19px;position: relative;bottom: 7px;" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="82845" width="200" height="200"><path d="M770.389333 512H814.933333a38.4 38.4 0 0 1 38.4 38.4v264.533333a38.4 38.4 0 0 1-38.4 38.4H550.4a38.4 38.4 0 0 1-38.4-38.4v-47.701333h215.722667a42.666667 42.666667 0 0 0 42.666666-42.666667V512zM253.610667 512H209.066667a38.4 38.4 0 0 1-38.4-38.4V209.066667A38.4 38.4 0 0 1 209.066667 170.666667h264.533333a38.4 38.4 0 0 1 38.4 38.4v47.701333H296.277333a42.666667 42.666667 0 0 0-42.666666 42.666667V512z" fill="#666666" p-id="82846"></path><path d="M298.666667 298.666667m51.2 0l324.266666 0q51.2 0 51.2 51.2l0 324.266666q0 51.2-51.2 51.2l-324.266666 0q-51.2 0-51.2-51.2l0-324.266666q0-51.2 51.2-51.2Z" fill="#000000" p-id="82847"></path></svg>
|
|
{{ end }}
|
|
</div>
|
|
{{ end }}
|
|
</div>
|
|
</div>
|
|
</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>
|
|
</div>
|
|
{{ end }} |