diff options
author | tdro <tdro@noreply.example.com> | 2022-05-31 16:00:55 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2022-05-31 16:00:55 -0400 |
commit | fab10521fbd303002b5adba8e026e4c8a8e73a44 (patch) | |
tree | 7d2db248af38e0658c116aa58de096cd24137204 /themes/default/layouts/_default/likes.html | |
parent | e06f465f528d69e5df5689c067fdfd4b33692eb0 (diff) | |
download | canory-fab10521fbd303002b5adba8e026e4c8a8e73a44.tar.gz canory-fab10521fbd303002b5adba8e026e4c8a8e73a44.tar.bz2 canory-fab10521fbd303002b5adba8e026e4c8a8e73a44.zip |
themes/default/layouts/_default/likes: Use intersect method and paginate properly.
Likes should be boolean.
Diffstat (limited to 'themes/default/layouts/_default/likes.html')
-rw-r--r-- | themes/default/layouts/_default/likes.html | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/themes/default/layouts/_default/likes.html b/themes/default/layouts/_default/likes.html index f1819b4..f37159c 100644 --- a/themes/default/layouts/_default/likes.html +++ b/themes/default/layouts/_default/likes.html @@ -31,24 +31,18 @@ {{ partial "profile.html" . }} - {{ $author := partial "author-user.html" . }} - {{ $count := 0 }} - {{ $result := false }} - - {{ range .Site.Pages }} - {{ if and (eq .Type $author) .Params.Liked }} - {{ $result = true }} - {{ $count = add $count 1 }} - {{ if le $count 10 }} - {{ .Render "summary" }} - {{ end }} - {{ end }} - {{ end }} - - {{ if not $result }} - <footer> - <code>No likes found!</code> - </footer> + {{- $author := partial "author-user.html" . -}} + {{- $users := where .Site.RegularPages "Section" $author -}} + {{- $likes := where .Site.RegularPages ".Params.liked" true -}} + {{- $filteredPages := $users | intersect $likes -}} + {{- $paginator := .Paginate $filteredPages }} + + {{ range $paginator.Pages }} + {{ .Render "summary" }} + {{ else }} + <footer> + <code>No likes found!</code> + </footer> {{ end }} {{ partial "pagination.html" . }} |