Created
February 24, 2020 12:42
-
-
Save Bertbk/8af2d93df8da3ddc5b1a90da4ab47ebe to your computer and use it in GitHub Desktop.
people widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{/* People Widget */}} | |
{{/* Initialise */}} | |
{{ $ := .root }} | |
{{ $page := .page }} | |
{{ $show_social := $page.Params.design.show_social | default false }} | |
{{ $show_interests := $page.Params.design.show_interests | default true }} | |
{{ $show_organizations := $page.Params.design.show_organizations | default false }} | |
<div class="row justify-content-center people-widget"> | |
{{ with $page.Title }} | |
<div class="col-md-12 section-heading"> | |
<h1>{{ . | markdownify | emojify }}</h1> | |
{{ if $page.Params.subtitle }}<p>{{ $page.Params.subtitle | markdownify | emojify }}</p>{{ end }} | |
</div> | |
{{ end }} | |
{{ with $page.Content }} | |
<div class="col-md-12"> | |
<p>{{ . }}</p> | |
</div> | |
{{ end }} | |
{{ range $page.Params.content.user_groups }} | |
<div class="col-md-12"> | |
<h2 class="mb-4">{{ . | markdownify }}</h2> | |
</div> | |
{{ $query := where (where site.Pages "Section" "authors") ".Params.user_groups" "intersect" (slice .) }} | |
{{ range $query }} | |
{{ $avatar := (.Resources.ByType "image").GetMatch "*avatar*" }} | |
{{/* Get link to user's profile page. */}} | |
{{ $link := "" }} | |
{{ with site.GetPage (printf "/authors/%s" (path.Base (path.Split .Path).Dir)) }} | |
{{ $link = .RelPermalink }} | |
{{ end }} | |
<div class="col-12 col-sm-auto people-person"> | |
{{ $src := "" }} | |
{{ if site.Params.avatar.gravatar }} | |
{{ $src = printf "https://s.gravatar.com/avatar/%s?s=150" (md5 .Params.email) }} | |
{{ else if $avatar }} | |
{{ $avatar_image := $avatar.Fill "270x270 Center" }} | |
{{ $src = $avatar_image.RelPermalink }} | |
{{ end }} | |
{{ if $src }} | |
{{ $avatar_shape := site.Params.avatar.shape | default "circle" }} | |
{{with $link}}<a href="{{.}}">{{end}}<img class="avatar {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="{{ $src }}" alt="Avatar">{{if $link}}</a>{{end}} | |
{{ end }} | |
<div class="portrait-title"> | |
<h2>{{with $link}}<a href="{{.}}">{{end}}{{ .Params.name }}{{if $link}}</a>{{end}}</h2> | |
{{ with .Params.role }}<h3>{{ . | markdownify | emojify }}</h3>{{ end }} | |
{{ if $show_social }}{{ partial "social_links" . }}{{ end }} | |
{{ if and $show_interests .Params.interests }}<p class="people-interests">{{ delimit . ", " | markdownify | emojify }}</p>{{ end }} | |
{{ if and $show_organizations .Params.organizations}} | |
{{ range .Params.organizations }} | |
<h3>{{ with .url }}<a href="{{ . }}" target="_blank" itemprop="url" rel="noopener">{{ end }} | |
<span itemprop="name">{{ .name }}</span> | |
{{ if .url }}</a>{{ end }} | |
</h3> | |
{{ end }} | |
{{ end }} | |
</div> | |
</div> | |
{{ end }} | |
{{ end }} | |
</div> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment