Perf: optimize posts order in collection list (#359)

This commit is contained in:
Cell
2023-12-27 15:10:36 +08:00
parent 7c7b81f589
commit 0c3148b3ee
3 changed files with 8 additions and 11 deletions
+1 -1
View File
@@ -27,7 +27,7 @@
<span title="{{ $title }}" class="icon-repost">{{- $icon | partial "plugin/icon.html" -}}</span>
{{- end -}}
{{- end -}}
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
</h2>
{{- /* Meta */ -}}
+3 -5
View File
@@ -4,9 +4,7 @@
{{- if .Params.collections | and $params.collectionList -}}
{{- $collectionTerms := .GetTerms "collections" -}}
{{- range $collectionTerms -}}
{{- $pages := .Pages -}}
{{- $prev := cond $.Site.Params.navigationReverse ($pages.Next $) ($pages.Prev $) -}}
{{- $next := cond $.Site.Params.navigationReverse ($pages.Prev $) ($pages.Next $) -}}
{{- $pages := (where .Pages "Params.Weight" "!=" nil) | append (where .Pages "Params.Weight" "eq" nil).ByDate -}}
{{- $open := eq (index $collectionTerms 0) . -}}
{{- $currentKey := 0 -}}
@@ -30,7 +28,7 @@
{{- end -}}
</ul>
<div class="collection-nav-simple">
{{- with $prev -}}
{{- with $pages.Next $ -}}
<a href="{{ .RelPermalink }}" class="collection-nav-item" rel="prev" title="{{ .LinkTitle }}">
{{- dict "Class" "fa-solid fa-angle-left fa-fw" | partial "plugin/icon.html" -}}
</a>
@@ -38,7 +36,7 @@
{{- dict "Class" "fa-solid fa-angle-left fa-fw collection-nav-item text-secondary" | partial "plugin/icon.html" -}}
{{- end -}}
<span class="text-secondary">{{ add $currentKey 1 }}/{{ $pages.Len }}</span>
{{- with $next -}}
{{- with $pages.Prev $ -}}
<a href="{{ .RelPermalink }}" class="collection-nav-item" rel="next" title="{{ .LinkTitle }}">
{{- dict "Class" "fa-solid fa-angle-right fa-fw" | partial "plugin/icon.html" -}}
</a>
+4 -5
View File
@@ -12,18 +12,17 @@
-}}
<div class="collection-card">
<div class="collection-title text-secondary">
{{ dict "Collections" $termLink | T "single.includedIn.collections" | safeHTML }} {{ .Pages.Len }}
{{- dict "Collections" $termLink | T "single.includedIn.collections" | safeHTML }} {{ .Pages.Len -}}
</div>
<div class="collection-nav">
{{- $prev := cond $.Site.Params.navigationReverse (.Pages.Next $) (.Pages.Prev $) -}}
{{- $next := cond $.Site.Params.navigationReverse (.Pages.Prev $) (.Pages.Next $) -}}
{{- with $prev -}}
{{- $pages := (where .Pages "Params.Weight" "!=" nil) | append (where .Pages "Params.Weight" "eq" nil).ByDate -}}
{{- with $pages.Next $ -}}
<a href="{{ .RelPermalink }}" class="collection-nav-item" rel="prev" title="{{ .LinkTitle }}">
{{- dict "Class" "fa-solid fa-angle-left fa-fw" | partial "plugin/icon.html" -}}
<span>{{- .LinkTitle -}}</span>
</a>
{{- end -}}
{{- with $next -}}
{{- with $pages.Prev $ -}}
<a href="{{ .RelPermalink }}" class="collection-nav-item" rel="next" title="{{ .LinkTitle }}">
<span>{{- .LinkTitle -}}</span>
{{- dict "Class" "fa-solid fa-angle-right fa-fw" | partial "plugin/icon.html" -}}