page_author.html 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. {{/* Author profile box */}}
  2. {{ if not (or (eq site.Params.profile false) (eq .Params.profile false)) }}
  3. {{/* Display superuser if superuser exists and page authors are not explicitly specified. */}}
  4. {{/* Otherwise, display first author if a profile for them exists. */}}
  5. {{ $author_urlized := "" }}
  6. {{ if and (not .Params.authors) (.Scratch.Get "superuser_username") }}
  7. {{ $author_urlized = (.Scratch.Get "superuser_username") }}
  8. {{ else }}
  9. {{ $first_author := "" }}
  10. {{ if .Params.authors }}
  11. {{ $first_author = index .Params.authors 0 }}
  12. {{ end }}
  13. {{ $author_urlized = urlize $first_author }}
  14. {{ end }}
  15. {{ $taxonomy := "authors" }}
  16. {{ $profile_page := site.GetPage (printf "/%s/%s" $taxonomy $author_urlized) }}
  17. {{ with $profile_page }}
  18. {{/* If it's a personal site and primary page author is superuser, link to the homepage rather than their profile page. */}}
  19. {{ $profile_url := .RelPermalink }}
  20. {{ if and (not site.Data.organization.name) (eq .Params.superuser true) }}
  21. {{ $profile_url = site.BaseURL }}
  22. {{ end }}
  23. {{ $avatar := (.Resources.ByType "image").GetMatch "*avatar*" }}
  24. <div class="media author-card" itemscope itemtype="http://schema.org/Person">
  25. {{ if and site.Params.gravatar .Params.email }}
  26. <img class="portrait mr-3" src="https://s.gravatar.com/avatar/{{ md5 .Params.email }}?s=200')" itemprop="image" alt="Avatar">
  27. {{ else if $avatar }}
  28. {{ $avatar_image := $avatar.Fill "250x250 Center" }}
  29. <img class="portrait mr-3" src="{{ $avatar_image.RelPermalink }}" itemprop="image" alt="Avatar">
  30. {{ end }}
  31. <div class="media-body">
  32. <h5 class="card-title" itemprop="name"><a href="{{$profile_url}}">{{.Params.name}}</a></h5>
  33. {{ with .Params.role }}<h6 class="card-subtitle">{{. | markdownify | emojify}}</h6>{{end}}
  34. {{ with .Params.bio }}<p class="card-text" itemprop="description">{{. | markdownify | emojify}}</p>{{end}}
  35. <ul class="network-icon" aria-hidden="true">
  36. {{ range .Params.social }}
  37. {{ $pack := or .icon_pack "fas" }}
  38. {{ $pack_prefix := $pack }}
  39. {{ if in (slice "fab" "fas" "far" "fal") $pack }}
  40. {{ $pack_prefix = "fa" }}
  41. {{ end }}
  42. {{ $link := .link }}
  43. {{ $scheme := (urls.Parse $link).Scheme }}
  44. {{ $target := "" }}
  45. {{ if not $scheme }}
  46. {{ $link = .link | relLangURL }}
  47. {{ else if in (slice "http" "https") $scheme }}
  48. {{ $target = "target=\"_blank\" rel=\"noopener\"" }}
  49. {{ end }}
  50. <li>
  51. <a itemprop="sameAs" href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }}>
  52. <i class="{{ $pack }} {{ $pack_prefix }}-{{ .icon }}"></i>
  53. </a>
  54. </li>
  55. {{end}}
  56. </ul>
  57. </div>
  58. </div>
  59. {{end}}{{/* Profile page block */}}
  60. {{end}}{{/* Show profile block */}}