page_author.html 2.4 KB

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