mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-14 04:15:40 +00:00
feat: show profile cards for all page authors, not just first author
If `site.Params.profile` is set to `true`, an author profile card will be displayed at the end of the page for every author (assuming that a profile has been setup for them under `content/authors/`). Close #1481
This commit is contained in:
1 parent
f9794e9f09
commit
63918091fb
2 files changed
+34
-32
No files matched your search
@@ -9,39 +9,12 @@
|
||||
{{ $author_urlized := "" }}
|
||||
{{ if and (not .Params.authors) (.Scratch.Get "superuser_username") }}
|
||||
{{ $author_urlized = (.Scratch.Get "superuser_username") }}
|
||||
{{ else }}
|
||||
{{ $first_author := "" }}
|
||||
{{ if .Params.authors }}
|
||||
{{ $first_author = index .Params.authors 0 }}
|
||||
{{ partial "page_author_card" (dict "username" $author_urlized) }}
|
||||
{{ else if .Params.authors }}
|
||||
{{ range $key, $tmp_username := .Params.authors }}
|
||||
{{ $author_urlized = urlize $tmp_username }}
|
||||
{{ partial "page_author_card" (dict "username" $author_urlized) }}
|
||||
{{ end }}
|
||||
{{ $author_urlized = urlize $first_author }}
|
||||
{{ end }}
|
||||
|
||||
{{ $site_type := site.Params.site_type | default "Person" }}
|
||||
{{ $taxonomy := "authors" }}
|
||||
{{ $profile_page := site.GetPage (printf "/%s/%s" $taxonomy $author_urlized) }}
|
||||
{{ with $profile_page }}
|
||||
{{/* If it's a personal site and primary page author is superuser, link to the homepage rather than their profile page. */}}
|
||||
{{ $profile_url := .RelPermalink }}
|
||||
{{ if and (eq $site_type "Person") (eq .Params.superuser true) }}
|
||||
{{ $profile_url = site.BaseURL }}
|
||||
{{ end }}
|
||||
{{ $avatar := (.Resources.ByType "image").GetMatch "*avatar*" }}
|
||||
{{ $avatar_shape := site.Params.avatar.shape | default "circle" }}
|
||||
<div class="media author-card content-widget-hr">
|
||||
{{ if and site.Params.avatar.gravatar .Params.email }}
|
||||
<img class="avatar mr-3 {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="https://s.gravatar.com/avatar/{{ md5 .Params.email }}?s=200')" alt="Avatar">
|
||||
{{ else if $avatar }}
|
||||
{{ $avatar_image := $avatar.Fill "270x270 Center" }}
|
||||
<img class="avatar mr-3 {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="{{ $avatar_image.RelPermalink }}" alt="Avatar">
|
||||
{{ end }}
|
||||
|
||||
<div class="media-body">
|
||||
<h5 class="card-title"><a href="{{$profile_url}}">{{.Params.name}}</a></h5>
|
||||
{{ with .Params.role }}<h6 class="card-subtitle">{{. | markdownify | emojify}}</h6>{{end}}
|
||||
{{ with .Params.bio }}<p class="card-text">{{. | markdownify | emojify}}</p>{{end}}
|
||||
{{ partial "social_links" . }}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}{{/* Profile page block */}}
|
||||
{{end}}{{/* Show profile block */}}
|
||||
@@ -0,0 +1,29 @@
|
||||
{{ $page := .page }}
|
||||
{{ $author_urlized := .username }}
|
||||
{{ $site_type := site.Params.site_type | default "Person" }}
|
||||
{{ $taxonomy := "authors" }}
|
||||
{{ $profile_page := site.GetPage (printf "/%s/%s" $taxonomy $author_urlized) }}
|
||||
{{ with $profile_page }}
|
||||
{{/* If it's a personal site and primary page author is superuser, link to the homepage rather than their profile page. */}}
|
||||
{{ $profile_url := .RelPermalink }}
|
||||
{{ if and (eq $site_type "Person") (eq .Params.superuser true) }}
|
||||
{{ $profile_url = site.BaseURL }}
|
||||
{{ end }}
|
||||
{{ $avatar := (.Resources.ByType "image").GetMatch "*avatar*" }}
|
||||
{{ $avatar_shape := site.Params.avatar.shape | default "circle" }}
|
||||
<div class="media author-card content-widget-hr">
|
||||
{{ if and site.Params.avatar.gravatar .Params.email }}
|
||||
<img class="avatar mr-3 {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="https://s.gravatar.com/avatar/{{ md5 .Params.email }}?s=200')" alt="Avatar">
|
||||
{{ else if $avatar }}
|
||||
{{ $avatar_image := $avatar.Fill "270x270 Center" }}
|
||||
<img class="avatar mr-3 {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="{{ $avatar_image.RelPermalink }}" alt="Avatar">
|
||||
{{ end }}
|
||||
|
||||
<div class="media-body">
|
||||
<h5 class="card-title"><a href="{{$profile_url}}">{{.Params.name}}</a></h5>
|
||||
{{ with .Params.role }}<h6 class="card-subtitle">{{. | markdownify | emojify}}</h6>{{end}}
|
||||
{{ with .Params.bio }}<p class="card-text">{{. | markdownify | emojify}}</p>{{end}}
|
||||
{{ partial "social_links" . }}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}{{/* Profile page block */}}
|
||||
Reference in new issue
Block a user