page_author.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. {{/* Author profile box */}}
  2. {{/* Don't show author box on normal pages or if author box disabled. */}}
  3. {{ if ne .Type "page" | and (not (or (eq site.Params.profile false) (eq .Params.profile false))) }}
  4. {{/* Display superuser if superuser exists and page authors are not explicitly specified. */}}
  5. {{/* Otherwise, display first author if a profile for them exists. */}}
  6. {{ $author_urlized := "" }}
  7. {{ if and (not .Params.authors) (.Scratch.Get "superuser_username") }}
  8. {{ $author_urlized = (.Scratch.Get "superuser_username") }}
  9. {{ else }}
  10. {{ $first_author := "" }}
  11. {{ if .Params.authors }}
  12. {{ $first_author = index .Params.authors 0 }}
  13. {{ end }}
  14. {{ $author_urlized = urlize $first_author }}
  15. {{ end }}
  16. {{ range $key, $value := $.Params.authors }}
  17. {{ $author := $value }}
  18. {{ $author_urlized = urlize $author }}
  19. {{ $site_type := site.Params.site_type | default "Person" }}
  20. {{ $taxonomy := "authors" }}
  21. {{ $profile_page := site.GetPage (printf "/%s/%s" $taxonomy $author_urlized) }}
  22. {{ with $profile_page }}
  23. {{/* If it's a personal site and primary page author is superuser, link to the homepage rather than their profile page. */}}
  24. {{ $profile_url := .RelPermalink }}
  25. {{ if and (eq $site_type "Person") (eq .Params.superuser true) }}
  26. {{ $profile_url = site.BaseURL }}
  27. {{ end }}
  28. {{ $avatar := (.Resources.ByType "image").GetMatch "*avatar*" }}
  29. <div class="media author-card content-widget-hr">
  30. {{ if and site.Params.gravatar .Params.email }}
  31. <img class="portrait mr-3" src="https://s.gravatar.com/avatar/{{ md5 .Params.email }}?s=200')" alt="Avatar">
  32. {{ else if $avatar }}
  33. {{ $avatar_image := $avatar.Fill "250x250 Center" }}
  34. <img class="portrait mr-3" src="{{ $avatar_image.RelPermalink }}" alt="Avatar">
  35. {{ end }}
  36. <div class="media-body">
  37. <h5 class="card-title"><a href="{{$profile_url}}">{{.Params.name}}</a></h5>
  38. {{ with .Params.role }}<h6 class="card-subtitle">{{. | markdownify | emojify}}</h6>{{end}}
  39. {{ with .Params.bio }}<p class="card-text">{{. | markdownify | emojify}}</p>{{end}}
  40. {{ partial "social_links" . }}
  41. </div>
  42. </div>
  43. {{end}}{{/* Profile page block */}}
  44. {{end}}{{/* Show profile block */}}
  45. {{end}}