portfolios_exemple2/themes/academia-hugo/layouts/partials/page_author.html

66 lines
2.8 KiB
HTML
Raw Normal View History

2021-12-31 12:44:26 +01:00
{{/* Author profile box */}}
{{ 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_urlized := "" }}
{{ if and (not .Params.authors) (.Scratch.Get "superuser_username") }}
{{ $author_urlized = (.Scratch.Get "superuser_username") }}
{{ else }}
{{ $first_author := "" }}
{{ if .Params.authors }}
{{ $first_author = index .Params.authors 0 }}
{{ end }}
{{ $author_urlized = urlize $first_author }}
{{ end }}
{{ $taxonomy := "authors" }}
{{ $profile_page := site.GetPage (printf "/%s/%s" $taxonomy $author_urlized) }}
{{ with $profile_page }}
{{/* If it's a personal site and primary page author is superuser, link to the homepage rather than their profile page. */}}
{{ $profile_url := .RelPermalink }}
{{ if and (not site.Data.organization.name) (eq .Params.superuser true) }}
{{ $profile_url = site.BaseURL }}
{{ end }}
{{ $avatar := (.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="{{$profile_url}}">{{.Params.name}}</a></h5>
{{ with .Params.role }}<h6 class="card-subtitle">{{. | markdownify | emojify}}</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}}{{/* Profile page block */}}
{{end}}{{/* Show profile block */}}