diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2022-05-14 09:58:34 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2022-05-14 09:58:34 +0200 |
| commit | 3858a4289a8a0e3f301975e3071fc2efb82334a0 (patch) | |
| tree | e9ccbb9d8c9b08a0d258b7389c65cf0874432422 /layouts/partials | |
| parent | d2ac62589a78a259ff930e352eb763abdcb958a2 (diff) | |
| download | gohugo-theme-ed-3858a4289a8a0e3f301975e3071fc2efb82334a0.tar.gz | |
Rework author partial
Diffstat (limited to 'layouts/partials')
| -rw-r--r-- | layouts/partials/author.html | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/layouts/partials/author.html b/layouts/partials/author.html index 8f2758f..6de4feb 100644 --- a/layouts/partials/author.html +++ b/layouts/partials/author.html @@ -1,9 +1,27 @@ -{{- if or .Params.author site.Params.author }} -{{- $author := (.Params.author | default site.Params.author) }} -{{- $author_type := (printf "%T" $author) }} -{{- if (or (eq $author_type "[]string") (eq $author_type "[]interface {}")) }} -{{- (delimit $author ", " ) }} +{{- /* First, check for current page author(s) */}} +{{- if .Params.author }} + {{- $author_type := (printf "%T" .Params.author) }} + {{- if (or (eq $author_type "[]string") (eq $author_type "[]interface {}")) }} + {{- (delimit .Params.author ", " ) }} + {{- else }} + {{- .Params.author }} + {{- end }} + +{{- /* Otherwise, get site authors */}} {{- else }} -{{- $author }} -{{- end }} + {{- if site.Author }} + {{- $author_type := (printf "%T" site.Author) }} + {{- if (or (eq $author_type "map[string]string") (eq $author_type "map[string]interface {}")) }} + {{- range $i, $author := site.Author }} + {{- $name_type := (printf "%T" $author) }} + {{- if (eq $name_type "maps.Params") }} + {{- with $author.name }}{{ $.Scratch.SetInMap "names" . . }}{{ end }} + {{- else }} + {{- $.Scratch.SetInMap "names" site.Author.name site.Author.name }} + {{- break -}} + {{- end }} + {{- end }} + {{- delimit ($.Scratch.GetSortedMapValues "names") ", " }} + {{- end }} + {{- end -}} {{- end -}} |
