diff options
author | tdro <tdro@noreply.example.com> | 2022-08-03 02:25:22 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2022-08-03 02:25:22 -0400 |
commit | eec7f7ea5d99e84ef2a9cf4594b18d1046ae3038 (patch) | |
tree | c3c4d9af65d5ecb6e7f91a52b1dc79fe6ba605fc | |
parent | 93ff2963616968f377d63f02bb0fa206144da7ae (diff) | |
download | canory-eec7f7ea5d99e84ef2a9cf4594b18d1046ae3038.tar.gz canory-eec7f7ea5d99e84ef2a9cf4594b18d1046ae3038.tar.bz2 canory-eec7f7ea5d99e84ef2a9cf4594b18d1046ae3038.zip |
themes/default/layouts/partials/author-list: Dry up author's slice
4 files changed, 13 insertions, 18 deletions
diff --git a/themes/default/layouts/_default/home.authors.html b/themes/default/layouts/_default/home.authors.html index db67566..c5e60e6 100644 --- a/themes/default/layouts/_default/home.authors.html +++ b/themes/default/layouts/_default/home.authors.html @@ -20,13 +20,9 @@ ) }} - {{ $authors := slice }} + {{ $authors := partial "function-authors-slice.html" . }} - {{- range $index, $data := .Site.Data -}} - {{- $authors = $authors | append $data.user -}} - {{- end -}} - - {{- range $author := (shuffle (uniq $authors)) -}} + {{- range $author := shuffle $authors -}} {{ $data := index $.Site.Data $author | default "default" }} {{ partial "author-card.html" (dict "Data" $data) }} {{ end }} diff --git a/themes/default/layouts/partials/author-list.html b/themes/default/layouts/partials/author-list.html index 127447f..37e3222 100644 --- a/themes/default/layouts/partials/author-list.html +++ b/themes/default/layouts/partials/author-list.html @@ -1,12 +1,9 @@ -{{ $authors := slice }} -{{ range $index, $data := .Site.Data -}} - {{- $authors = $authors | append $data.user -}} -{{- end -}} +{{- $authors := partial "function-authors-slice.html" . -}} <author-list> <h1>Authors</h1> <aside> - {{- range $author := first 3 (shuffle (uniq $authors)) -}} + {{- range $author := first 3 (shuffle $authors) -}} {{ $data := index $.Site.Data $author | default "default" }} {{ partial "author-card.html" (dict "Data" $data) }} {{ end }} diff --git a/themes/default/layouts/partials/count-authors.html b/themes/default/layouts/partials/count-authors.html index 00655a0..2b46b52 100644 --- a/themes/default/layouts/partials/count-authors.html +++ b/themes/default/layouts/partials/count-authors.html @@ -1,7 +1,2 @@ -{{- $authors := slice -}} - -{{- range $index, $data := .Site.Data -}} - {{- $authors = $authors | append $data.name -}} -{{- end -}} - -{{- print (lang.FormatNumberCustom 0 (len (uniq $authors))) " " "Authors" -}} +{{- $authors := partial "function-authors-slice.html" . -}} +{{- print (lang.FormatNumberCustom 0 (len $authors)) " " "Authors" -}} diff --git a/themes/default/layouts/partials/function-authors-slice.html b/themes/default/layouts/partials/function-authors-slice.html new file mode 100644 index 0000000..a469fdd --- /dev/null +++ b/themes/default/layouts/partials/function-authors-slice.html @@ -0,0 +1,7 @@ +{{- $authors := slice -}} + +{{- range $index, $author := .Site.Data -}} + {{- $authors = $authors | append $author.user -}} +{{- end -}} + +{{- return (uniq $authors) -}} |