page_author.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. {{ $avatar := (.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="{{.RelPermalink}}">{{.Params.name}}</a></h5>
  28. {{ with .Params.role }}<h6 class="card-subtitle">{{. | markdownify | emojify}}</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}}{{/* Profile page block */}}
  55. {{end}}{{/* Show profile block */}}