49 lines
2.6 KiB
HTML
49 lines
2.6 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 style="position: relative;top: -8px;right: 6px;color: #848282;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="currentColor"><path d="M13.8273 1.69L22.3126 10.1753L20.8984 11.5895L20.1913 10.8824L15.9486 15.125L15.2415 18.6606L13.8273 20.0748L9.58466 15.8321L4.63492 20.7819L3.2207 19.3677L8.17045 14.4179L3.92781 10.1753L5.34202 8.76107L8.87756 8.05396L13.1202 3.81132L12.4131 3.10422L13.8273 1.69ZM14.5344 5.22554L9.86358 9.89637L7.0417 10.4607L13.5418 16.9609L14.1062 14.139L18.7771 9.46818L14.5344 5.22554Z"></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 }} |