mirror of
https://github.com/gcushen/hugo-academic.git
synced 2025-08-02 05:41:16 +02:00
Requires Hugo v0.55.2+. Does not work with Hugo v0.55.0 due to bugs fixed in v0.55.2. Fix #1017
59 lines
2.4 KiB
HTML
59 lines
2.4 KiB
HTML
{{ if not (or (eq .Site.Params.profile false) (eq .Params.profile false)) }}
|
|
|
|
{{/* Display superuser if superuser exists and page authors are not explicitly specified. */}}
|
|
{{/* Otherwise, display first author if a profile for them exists. */}}
|
|
|
|
{{ $author_urlize := "" }}
|
|
{{ if and (not .Params.authors) (.Scratch.Get "superuser_username") }}
|
|
{{ $author_urlize = (.Scratch.Get "superuser_username") }}
|
|
{{ else }}
|
|
{{ $first_author := "" }}
|
|
{{ if .Params.authors }}
|
|
{{ $first_author = index .Params.authors 0 }}
|
|
{{ end }}
|
|
{{ $author_urlize = urlize $first_author }}
|
|
{{ end }}
|
|
|
|
{{ $person_page_path := (printf "/author/%s" $author_urlize) }}
|
|
{{ $person_page := site.GetPage $person_page_path }}
|
|
{{ with $person_page }}
|
|
{{ $link := printf "/authors/%s" $author_urlize | relURL }}
|
|
{{ $avatar := ($person_page.Resources.ByType "image").GetMatch "*avatar*" }}
|
|
<div class="media author-card" itemscope itemtype="http://schema.org/Person">
|
|
{{ if and site.Params.gravatar .Params.email }}
|
|
<img class="portrait mr-3" src="https://s.gravatar.com/avatar/{{ md5 .Params.email }}?s=200')" itemprop="image" alt="Avatar">
|
|
{{ else if $avatar }}
|
|
{{ $avatar_image := $avatar.Fill "250x250 Center" }}
|
|
<img class="portrait mr-3" src="{{ $avatar_image.RelPermalink }}" itemprop="image" alt="Avatar">
|
|
{{ end }}
|
|
|
|
<div class="media-body">
|
|
<h5 class="card-title" itemprop="name"><a href="{{ $link }}">{{ .Params.name }}</a></h5>
|
|
{{ with .Params.role }}<h6 class="card-subtitle">{{.}}</h6>{{end}}
|
|
{{ with .Params.bio }}<p class="card-text" itemprop="description">{{. | markdownify | emojify}}</p>{{end}}
|
|
<ul class="network-icon" aria-hidden="true">
|
|
{{ range .Params.social }}
|
|
{{ $pack := or .icon_pack "fas" }}
|
|
{{ $pack_prefix := $pack }}
|
|
{{ if in (slice "fab" "fas" "far" "fal") $pack }}
|
|
{{ $pack_prefix = "fa" }}
|
|
{{ end }}
|
|
{{ $link := .link }}
|
|
{{ $scheme := (urls.Parse $link).Scheme }}
|
|
{{ $target := "" }}
|
|
{{ if not $scheme }}
|
|
{{ $link = .link | relLangURL }}
|
|
{{ else if in (slice "http" "https") $scheme }}
|
|
{{ $target = "target=\"_blank\" rel=\"noopener\"" }}
|
|
{{ end }}
|
|
<li>
|
|
<a itemprop="sameAs" href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }}>
|
|
<i class="{{ $pack }} {{ $pack_prefix }}-{{ .icon }}"></i>
|
|
</a>
|
|
</li>
|
|
{{ end }}
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
{{end}}
|