portfolios_lea-jean/layouts/partials/page_author.html
2022-02-16 18:17:14 +01:00

66 lines
2.9 KiB
HTML

{{/* 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 $avatar }}
{{ $avatar_image := $avatar.Fill "250x250 Center" }}
<img class="portrait mr-3" src="{{ $avatar_image.RelPermalink }}" itemprop="image" alt="Avatar">
{{else}}
<img src="{{ printf "/img/leebit.png" | relURL }}" alt="Profil" height="80" width="80">
{{ end }}
<div class="media-body">
<h5 class="card-title" style="display:flex; justify-content:center;" itemprop="name"><a href="{{$profile_url}}">{{.Params.name}}</a></h5>
{{ with .Params.role }}<h6 class="card-subtitle" style="display:flex; justify-content:center;">{{. | markdownify | emojify}}</h6>{{end}}
{{ with .Params.bio }}<p class="card-text" style="display:flex; justify-content:center;" itemprop="description">{{. | markdownify | emojify}}</p>{{end}}
<ul class="network-icon" style="display:flex; justify-content:center;" 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 */}}