Add authors taxonomy

This commit is contained in:
Will Faught
2023-03-15 19:51:52 -07:00
parent a66f33962c
commit 062c45579d
6 changed files with 64 additions and 22 deletions

View File

@@ -1,33 +1,32 @@
{{ $page := . }}
{{ $result := "" }}
{{ $result := slice }}
{{ if $page.Params.authors }}
{{ $names := slice }}
{{ range $page.Params.authors }}
{{ if eq (printf "%T" .) "string" }}
{{ $names = $names | append (index site.Params.authors .).name }}
{{ else }}
{{ $id := "" }}
{{ $name := "" }}
{{ if reflect.IsMap . }}
{{ with .author }}
{{ $names = $names | append (index site.Params.authors .).name }}
{{ $id = . }}
{{ $name = (index site.Params.authors .).name }}
{{ else }}
{{ $names = $names | append .name }}
{{ $name = .name }}
{{ end }}
{{ else }}
{{ $id = . }}
{{ $name = (index site.Params.authors .).name }}
{{ end }}
{{ $result = $result | append (dict "id" $id "name" $name) }}
{{ end }}
{{ $result = delimit $names ", " }}
{{ else if site.Params.authors }}
{{ $names := slice }}
{{ range $k, $v := site.Params.authors }}
{{ if eq $v.default true }}
{{ $names = $names | append $v.name }}
{{ $result = $result | append (dict "id" $k "name" $v.name) }}
{{ end }}
{{ end }}
{{ $result = delimit $names ", " }}
{{ end }}
{{ return $result }}

View File

@@ -72,7 +72,21 @@
{{ end }}
{{ with $authors }}
<p class="mb-0 {{ if $class }} paige-authors {{ end }} text-center text-secondary" {{ if $id }} id="paige-authors" {{ end }}>{{ . }}</p>
<p class="mb-0 {{ if $class }} paige-authors {{ end }} text-center text-secondary" {{ if $id }} id="paige-authors" {{ end }}>
{{ range $i, $author := . -}}
{{- if gt $i 0 }}, {{ end -}}
{{- with $author.id -}}
{{- with site.GetPage (print "authors/" .) -}}
<a class="link-secondary text-decoration-none" href="{{ .RelPermalink }}">{{ .Title | default $author.name }}</a>
{{- else -}}
{{- $author.name -}}
{{- end -}}
{{- else -}}
{{- $author.name -}}
{{- end -}}
{{- end }}
</p>
{{ end }}
{{ with $date }}

View File

@@ -90,7 +90,21 @@
{{ end }}
{{ with $authors }}
<p class="mb-0 paige-authors text-center text-secondary">{{ . }}</p>
<p class="mb-0 paige-authors text-center text-secondary">
{{ range $i, $author := . -}}
{{- if gt $i 0 }}, {{ end -}}
{{- with $author.id -}}
{{- with site.GetPage (print "authors/" .) -}}
<a class="link-secondary text-decoration-none" href="{{ .RelPermalink }}">{{ .Title | default $author.name }}</a>
{{- else -}}
{{- $author.name -}}
{{- end -}}
{{- else -}}
{{- $author.name -}}
{{- end -}}
{{- end }}
</p>
{{ end }}
{{ with $date }}