How can I list the authors who have at least one article in the content/articles
section of my website ? The difficulty I encounter is to avoid listing authors from only other sections, e.g. content/books
.
Currently, I have the following code:
{{- with (.Site.GetPage "taxonomyTerm" "authors") -}}
{{ $authors := .Pages }}
{{- range $i, $author := $authors -}} {{/* Trick from https://discourse.gohugo.io/t/howto-delimiter-separated-tags/146 */}}
{{- $NArticles := len (where $author.Pages "Section" "articles") -}}
{{- if ge $NJointArticles 1 -}}
{{- if $i -}}, {{ end }}
<a href="{{ $author.Params.website }}">{{- $author.Title -}}</a>
{{- end -}}
{{- end -}}
{{end}}
It works, but this is not very satisfactory. I think that if the first author (alphabetically) is to be excluded because he did not author in the content/articles
section, my comma separated list will be messed up and it will start by a comma.