page_author.html 2.7 KB

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