{{ define "main" }}
  {{ $text := .Content }}
  {{ $.Scratch.Set "committee_member" slice }}
  {{ $.Scratch.Set "speaker_at_events" slice }}

  {{ with (index .Site.Data.personen (substr $.File.LogicalName 0 -3)) }}
    {{ $personid := .id }}
    {{ if .thumbnail }}
      {{ $alttext := printf "Foto van %s" .name }}
      {{ partial "show-image.html" (dict "context" . "image" .thumbnail "above_the_fold" true "alt" $alttext) }}
    {{ end }}
    {{ $text }}

    {{ range where $.Site.RegularPages.ByTitle "Section" "organisatie" }}
      {{ if .Params.team_members }}
        {{ if in .Params.team_members $personid }}
          {{ $.Scratch.Add "committee_member" . }}
        {{ end }}
      {{ end }}
    {{ end }}

    {{ if (gt ($.Scratch.Get "committee_member" | len) 0) }}
      <h2>Organisatie</h2>
      <p>{{ .name }} is actief binnen de volgende teams/commissies:</p>
      <ul>
          {{ range $.Scratch.Get "committee_member" }}
            <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
          {{ end }}
      </ul>
    {{ end }}

    {{ range where $.Site.RegularPages "Section" "evenementen" }}
      {{ if .Params.speakers }}
        {{ if in .Params.speakers $personid }}
          {{ $.Scratch.Add "speaker_at_events" . }}
        {{ end }}
      {{ end }}
    {{ end }}

    {{ if (gt ($.Scratch.Get "speaker_at_events" | len) 0) }}
      <h2>Presentaties</h2>
      <ul>
        {{ range $.Scratch.Get "speaker_at_events" }}
          <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
        {{ end }}
      </ul>
    {{ end }}

    {{ if or (.email) (.websites) }}
      <h2>Contact</h2>
      <ul>
      {{ if .email }}<li>E-mail: {{ .email }}</li>{{ end }}
      {{ if .websites }}
          {{ range .websites }}
            <li><a href="{{ .url }}" rel="nofollow noopener">{{ .name }}</a></li>
            {{ end }}
      {{ end }}
      </ul>
    {{ end }}

    {{ if or (.social.hubzilla) (.social.github) (.social.gitlab) (.social.linkedin) (.social.mastodon) (.social.twitter) }}
      <h2>Social media</h2>

      <ul class="list">
      {{ if .social.github }}
        <li><img class="m-r-small" src="/afbeeldingen/iconen/github.svg" height="{{ $.Site.Params.smallIconSize }}" width="{{ $.Site.Params.smallIconSize }}" alt="GitHub-icoon"> <a href="https://github.com/{{ .social.github }}">{{ .social.github }}</a></li>
      {{ end }}
      {{ if .social.gitlab }}
        <li><img class="m-r-small" src="/afbeeldingen/iconen/gitlab.svg" height="{{ $.Site.Params.smallIconSize }}" width="{{ $.Site.Params.smallIconSize }}" alt="GitLab-icoon"> <a href="https://gitlab.com/{{ .social.gitlab }}">{{ .social.gitlab }}</a></li>
      {{ end }}
      {{ if .social.hubzilla }}
        <li><img class="m-r-small" src="/afbeeldingen/iconen/message.svg" height="{{ $.Site.Params.smallIconSize }}" width="{{ $.Site.Params.smallIconSize }}" alt="Hubzilla-icoon"> <a href="{{ .social.hubzilla_url }}">{{ .social.hubzilla }}</a></li>
      {{ end }}
      {{ if .social.linkedin }}
        <li><img class="m-r-small" src="/afbeeldingen/iconen/linkedin.svg" height="{{ $.Site.Params.smallIconSize }}" width="{{ $.Site.Params.smallIconSize }}" alt="LinkedIn-icoon"> <a href="{{ .social.linkedin }}">LinkedIn</a></li>
      {{ end }}
      {{ if .social.mastodon }}
        <li><img class="m-r-small" src="/afbeeldingen/iconen/mastodon.svg" height="{{ $.Site.Params.smallIconSize }}" width="{{ $.Site.Params.smallIconSize }}" alt="Mastodon-icoon"> <a href="{{ .social.mastodon_url }}">{{ .social.mastodon }}</a></li>
      {{ end }}
      {{ if .social.twitter }}
        <li><img class="m-r-small" src="/afbeeldingen/iconen/twitter.svg" height="{{ $.Site.Params.smallIconSize }}" width="{{ $.Site.Params.smallIconSize }}" alt="Twitter-icoon"> <a href="https://twitter.com/{{ .social.twitter }}">{{ .social.twitter }}</a></li>
      {{ end }}
      </ul>
    {{ end }}

  {{ end }}
{{ end }}