aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-05-31 16:00:55 -0400
committertdro <tdro@noreply.example.com>2022-05-31 16:00:55 -0400
commitfab10521fbd303002b5adba8e026e4c8a8e73a44 (patch)
tree7d2db248af38e0658c116aa58de096cd24137204
parente06f465f528d69e5df5689c067fdfd4b33692eb0 (diff)
downloadcanory-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.
-rw-r--r--content/canory/messages/pinned.md2
-rw-r--r--themes/default/layouts/_default/likes.html30
2 files changed, 13 insertions, 19 deletions
diff --git a/content/canory/messages/pinned.md b/content/canory/messages/pinned.md
index d00fb1b..1e1bd16 100644
--- a/content/canory/messages/pinned.md
+++ b/content/canory/messages/pinned.md
@@ -3,7 +3,7 @@ date = "2022-02-05T02:20:51+00:00"
lastmod = "2022-03-29T22:55:17+00:00"
tags = [ "docs", "pinned", "hugo" ]
weight = 1
-liked = 1
+liked = true
author = "canory"
+++
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" . }}