80 lines
4.2 KiB
HTML
80 lines
4.2 KiB
HTML
{{ define "main" }}
|
|
<div id="pjax-container">
|
|
<article>
|
|
<div class="recent-posts section">
|
|
<!-- Searchable Header Container -->
|
|
<div class="searchable-header-container">
|
|
<h2 class="section-header normal-mode" id="essay-header" onclick="toggleSearchMode(true)" uk-scrollspy="cls: uk-animation-slide-left-small; delay: 200">
|
|
随笔<i class="ri-quill-pen-line"></i>
|
|
<div class="search-hint-wrapper">
|
|
{{ if .Site.Params.home_search.mascot }}
|
|
<img src="{{ .Site.Params.home_search.mascot | relURL }}" class="search-mascot">
|
|
{{ else }}
|
|
<img src="{{ "emotion/aru/cheer.png" | relURL }}" class="search-mascot">
|
|
{{ end }}
|
|
<span class="search-hint"></span>
|
|
</div>
|
|
{{ if .Site.Params.home_search.hint }}
|
|
<script>
|
|
window.searchHintText = "{{ .Site.Params.home_search.hint }}";
|
|
window.searchGreetings = {{ .Site.Params.home_search.greetings | jsonify | safeJS }};
|
|
window.searchHolidays = {{ .Site.Params.home_search.holidays | jsonify | safeJS }};
|
|
</script>
|
|
{{ end }}
|
|
</h2>
|
|
<div class="search-mode" id="search-container" style="display: none;">
|
|
<div class="search-input-group">
|
|
<i class="ri-search-line search-icon"></i>
|
|
<input type="text" id="inline-search-input" placeholder="搜索文章..." autocomplete="off">
|
|
<i class="ri-close-line close-icon" onclick="toggleSearchMode(false)"></i>
|
|
</div>
|
|
</div>
|
|
<div id="inline-search-results" class="search-dropdown"></div>
|
|
</div>
|
|
|
|
<div class="posts" uk-scrollspy="target: > .post; cls: uk-animation-slide-bottom-small; delay: 100">
|
|
<!-- 使用 sort 对文章按 Weight 排序 -->
|
|
{{ $posts := sort (where (where .Site.RegularPages "Type" "post") "Params.status" "ne" "hidden")
|
|
"Weight" }}
|
|
{{ $exclude := where $posts "Params.categories" "intersect" (slice "笔记") }}
|
|
{{ $posts = $posts | complement $exclude }}
|
|
{{ $paginator := .Paginate $posts }}
|
|
|
|
{{ range $paginator.Pages }}
|
|
<div class="post">
|
|
<div class="time">{{ .Date.Format "January 2, 2006" }}</div>
|
|
<a href="{{ .RelPermalink }}">{{ .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 图标 -->
|
|
<img src="/image/zd_top.png" alt="" srcset="" style="width: 19px;position: relative;bottom: 2px;right: 3px;box-shadow: 0 0px 0px rgba(0, 0, 0, 0.2);cursor: pointer;transform: 1s;">
|
|
{{ 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 }} |