Skip to content

Commit

Permalink
⚡ Perf: optimize posts order in collection list (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Dec 27, 2023
1 parent 7c7b81f commit 0c3148b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion layouts/_default/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h2 class="single-title" itemprop="name headline">
<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 */ -}}
Expand Down
8 changes: 3 additions & 5 deletions layouts/partials/single/collection-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}

Expand All @@ -30,15 +28,15 @@
{{- 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>
{{- else -}}
{{- 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>
Expand Down
9 changes: 4 additions & 5 deletions layouts/partials/single/collection-nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -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" -}}
Expand Down

0 comments on commit 0c3148b

Please sign in to comment.