Skip to content

Commit

Permalink
feat: add simple Avatar variation of About widget
Browse files Browse the repository at this point in the history
  • Loading branch information
gcushen committed Aug 30, 2021
1 parent 81345fa commit 8b6612e
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions wowchemy/layouts/partials/widgets/about.avatar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{{ $ := .root }}
{{ $page := .page }}

{{ $author := "" }}
{{ if .author }}
{{ $author = .author }}
{{ else }}
{{ $author = $page.Params.author }}
{{end}}

{{ $person_page_path := (printf "/authors/%s" $author) }}
{{ $person_page := site.GetPage $person_page_path }}
{{ if not $person_page }}
{{ errorf "Could not find an author page at `%s`. Please check the value of `author` in your About widget and create an associated author page if one does not already exist. See https://wowchemy.com/docs/page-builder/#about " $person_page_path }}
{{end}}
{{ $person := $person_page.Params }}
{{ $avatar := ($person_page.Resources.ByType "image").GetMatch "*avatar*" }}
{{ $avatar_shape := site.Params.avatar.shape | default "circle" }}

<div id="profile">

{{ if site.Params.avatar.gravatar }}
<img class="avatar {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="https://s.gravatar.com/avatar/{{ md5 $person.email }}?s=150')" alt="{{$person_page.Title}}">
{{ else if $avatar }}
{{ $avatar_image := $avatar.Fill "150x150 Center" }}
<img class="avatar {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="{{ $avatar_image.RelPermalink }}" alt="{{$person_page.Title}}">
{{ end }}

<div class="portrait-title">
<h2>{{ $person_page.Title }}</h2>
{{ with $person.role }}<h3>{{ . | markdownify | emojify }}</h3>{{ end }}

{{ range $person.organizations }}
<h3>
{{ with .url }}<a href="{{ . }}" target="_blank" rel="noopener">{{ end }}
<span>{{ .name }}</span>
{{ if .url }}</a>{{ end }}
</h3>
{{ end }}
</div>

<ul class="network-icon" aria-hidden="true">
{{ range $person.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 href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }} aria-label="{{ .icon }}">
<i class="{{ $pack }} {{ $pack_prefix }}-{{ .icon }} big-icon"></i>
</a>
</li>
{{ end }}
</ul>

</div>

0 comments on commit 8b6612e

Please sign in to comment.