{{/* Get name of primary author. */}}

{{ $page := . }}

{{/* Get publisher as fall back. */}}
{{ $branding := partialCached "functions/get_branding" $page "branding" }}
{{ $publisher := $branding.organization }}

{{ $author := "" }}
{{ $author_slug := "" }}

{{ if and (not $page.Params.authors) ($page.Scratch.Get "superuser_slug") }}
  {{ $author_slug = $page.Scratch.Get "superuser_slug" }}
{{ else if $page.Params.authors }}
  {{ $author = index $page.Params.authors 0 }}
  {{ $author_slug = urlize $author }}
{{ end }}

{{ $profile := partial "functions/get_author_profile" (dict "slug" $author_slug) }}
{{ if $profile.title }}
  {{ $author = $profile.title }}
{{ else }}
  {{ $author = $author | default $publisher }}
{{ end }}

{{ return $author }}
