page_author.html 2.9 KB

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