page_author.html 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. {{ $site_type := site.Params.site_type | default "Person" }}
  17. {{ $taxonomy := "authors" }}
  18. {{ $profile_page := site.GetPage (printf "/%s/%s" $taxonomy $author_urlized) }}
  19. {{ with $profile_page }}
  20. {{/* If it's a personal site and primary page author is superuser, link to the homepage rather than their profile page. */}}
  21. {{ $profile_url := .RelPermalink }}
  22. {{ if and (eq $site_type "Person") (eq .Params.superuser true) }}
  23. {{ $profile_url = site.BaseURL }}
  24. {{ end }}
  25. {{ $avatar := (.Resources.ByType "image").GetMatch "*avatar*" }}
  26. <div class="media author-card content-widget-hr">
  27. {{ if and site.Params.gravatar .Params.email }}
  28. <img class="portrait mr-3" src="https://s.gravatar.com/avatar/{{ md5 .Params.email }}?s=200')" alt="Avatar">
  29. {{ else if $avatar }}
  30. {{ $avatar_image := $avatar.Fill "250x250 Center" }}
  31. <img class="portrait mr-3" src="{{ $avatar_image.RelPermalink }}" alt="Avatar">
  32. {{ end }}
  33. <div class="media-body">
  34. <h5 class="card-title"><a href="{{$profile_url}}">{{.Params.name}}</a></h5>
  35. {{ with .Params.role }}<h6 class="card-subtitle">{{. | markdownify | emojify}}</h6>{{end}}
  36. {{ with .Params.bio }}<p class="card-text">{{. | markdownify | emojify}}</p>{{end}}
  37. {{ partial "social_links" . }}
  38. </div>
  39. </div>
  40. {{end}}{{/* Profile page block */}}
  41. {{end}}{{/* Show profile block */}}